Class MultiplierSubstitution

java.lang.Object
com.ibm.icu.text.NFSubstitution
com.ibm.icu.text.MultiplierSubstitution

class MultiplierSubstitution extends NFSubstitution
A substitution that divides the number being formatted by the rule's divisor and formats the quotient. Represented by << in normal rules.
  • Field Details

    • divisor

      long divisor
      The divisor of the rule that owns this substitution.
    • owningRule

      NFRule owningRule
      A backpointer to the owning rule. Used in the rounding logic to determine whether the owning rule also has a modulus substitution.
  • Constructor Details

    • MultiplierSubstitution

      MultiplierSubstitution(int pos, NFRule rule, NFRuleSet ruleSet, String description)
      Constructs a MultiplierSubstitution. This uses the superclass constructor to initialize most members, but this substitution also maintains its own copy of its rule's divisor.
      Parameters:
      pos - The substitution's position in its rule's rule text
      rule - The rule that owns this substitution
      ruleSet - The ruleSet this substitution uses to format its result
      description - The description describing this substitution
  • Method Details

    • setDivisor

      public void setDivisor(int radix, short exponent)
      Sets the substitution's divisor based on the values passed in.
      Overrides:
      setDivisor in class NFSubstitution
      Parameters:
      radix - The radix of the divisor.
      exponent - The exponent of the divisor.
    • equals

      public boolean equals(Object that)
      Augments the superclass's equals() function by comparing divisors.
      Overrides:
      equals in class NFSubstitution
      Parameters:
      that - The other substitution
      Returns:
      true if the two substitutions are functionally equal
    • transformNumber

      public long transformNumber(long number)
      Divides the number by the rule's divisor and returns the quotient.
      Specified by:
      transformNumber in class NFSubstitution
      Parameters:
      number - The number being formatted.
      Returns:
      "number" divided by the rule's divisor
    • transformNumber

      public double transformNumber(double number)
      Divides the number by the rule's divisor and returns the quotient. This is an integral quotient if we're filling in the substitution using another rule set, but it's the full quotient (integral and fractional parts) if we're filling in the substitution using a DecimalFormat. (This allows things such as "1.2 million".)
      Specified by:
      transformNumber in class NFSubstitution
      Parameters:
      number - The number being formatted
      Returns:
      "number" divided by the rule's divisor
    • composeRuleValue

      public double composeRuleValue(double newRuleValue, double oldRuleValue)
      Returns newRuleValue times the divisor. Ignores oldRuleValue. (The result of matching a invalid input: '<'invalid input: '<' substitution supersedes the base value of the rule that contains it.)
      Specified by:
      composeRuleValue in class NFSubstitution
      Parameters:
      newRuleValue - The result of matching the substitution
      oldRuleValue - The base value of the rule containing the substitution
      Returns:
      newRuleValue * divisor
    • calcUpperBound

      public double calcUpperBound(double oldUpperBound)
      Sets the upper bound down to the rule's divisor.
      Specified by:
      calcUpperBound in class NFSubstitution
      Parameters:
      oldUpperBound - Ignored.
      Returns:
      The rule's divisor.
    • tokenChar

      char tokenChar()
      The token character for a multiplier substitution is <.
      Specified by:
      tokenChar in class NFSubstitution
      Returns:
      '<'