Class Scale


  • public class Scale
    extends java.lang.Object
    A class that defines a quantity by which a number should be multiplied when formatting.

    To create a Multiplier, use one of the factory methods.

    See Also:
    NumberFormatter
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Scale​(int magnitude, java.math.BigDecimal arbitrary)  
      private Scale​(int magnitude, java.math.BigDecimal arbitrary, java.math.MathContext mc)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void applyReciprocalTo​(DecimalQuantity quantity)
      Deprecated.
      ICU 62 This API is ICU internal only.
      void applyTo​(DecimalQuantity quantity)
      Deprecated.
      ICU 62 This API is ICU internal only.
      static Scale byBigDecimal​(java.math.BigDecimal multiplicand)
      Multiply numbers by an arbitrary value before formatting.
      static Scale byDouble​(double multiplicand)
      Multiply numbers by an arbitrary value before formatting.
      static Scale byDoubleAndPowerOfTen​(double multiplicand, int power)
      Multiply a number by both a power of ten and by an arbitrary double value before formatting.
      (package private) boolean isValid()
      Returns whether the multiplier will change the number.
      static Scale none()
      Do not change the value of numbers when formatting or parsing.
      static Scale powerOfTen​(int power)
      Multiply numbers by 100 before formatting.
      Scale withMathContext​(java.math.MathContext mc)
      Deprecated.
      ICU 62 This API is ICU internal only.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT

        private static final Scale DEFAULT
      • HUNDRED

        private static final Scale HUNDRED
      • THOUSAND

        private static final Scale THOUSAND
      • BIG_DECIMAL_100

        private static final java.math.BigDecimal BIG_DECIMAL_100
      • BIG_DECIMAL_1000

        private static final java.math.BigDecimal BIG_DECIMAL_1000
      • magnitude

        final int magnitude
      • arbitrary

        final java.math.BigDecimal arbitrary
      • reciprocal

        final java.math.BigDecimal reciprocal
      • mc

        final java.math.MathContext mc
    • Constructor Detail

      • Scale

        private Scale​(int magnitude,
                      java.math.BigDecimal arbitrary)
      • Scale

        private Scale​(int magnitude,
                      java.math.BigDecimal arbitrary,
                      java.math.MathContext mc)
    • Method Detail

      • none

        public static Scale none()
        Do not change the value of numbers when formatting or parsing.
        Returns:
        A Multiplier to prevent any multiplication.
        See Also:
        NumberFormatter
      • powerOfTen

        public static Scale powerOfTen​(int power)
        Multiply numbers by 100 before formatting. Useful for combining with a percent unit:
         NumberFormatter.with().unit(NoUnit.PERCENT).multiplier(Multiplier.powerOfTen(2))
         
        Returns:
        A Multiplier for passing to the setter in NumberFormatter.
        See Also:
        NumberFormatter
      • byBigDecimal

        public static Scale byBigDecimal​(java.math.BigDecimal multiplicand)
        Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.

        This method takes a BigDecimal; also see the version that takes a double.

        Returns:
        A Multiplier for passing to the setter in NumberFormatter.
        See Also:
        NumberFormatter
      • byDouble

        public static Scale byDouble​(double multiplicand)
        Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.

        This method takes a double; also see the version that takes a BigDecimal.

        Returns:
        A Multiplier for passing to the setter in NumberFormatter.
        See Also:
        NumberFormatter
      • byDoubleAndPowerOfTen

        public static Scale byDoubleAndPowerOfTen​(double multiplicand,
                                                  int power)
        Multiply a number by both a power of ten and by an arbitrary double value before formatting.
        Returns:
        A Multiplier for passing to the setter in NumberFormatter.
        See Also:
        NumberFormatter
      • isValid

        boolean isValid()
        Returns whether the multiplier will change the number.
      • withMathContext

        @Deprecated
        public Scale withMathContext​(java.math.MathContext mc)
        Deprecated.
        ICU 62 This API is ICU internal only.
      • applyTo

        @Deprecated
        public void applyTo​(DecimalQuantity quantity)
        Deprecated.
        ICU 62 This API is ICU internal only.
      • applyReciprocalTo

        @Deprecated
        public void applyReciprocalTo​(DecimalQuantity quantity)
        Deprecated.
        ICU 62 This API is ICU internal only.