Package com.ibm.icu.text
Class MultiplierSubstitution
java.lang.Object
com.ibm.icu.text.NFSubstitution
com.ibm.icu.text.MultiplierSubstitution
A substitution that divides the number being formatted by the rule's
divisor and formats the quotient. Represented by << in normal
rules.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) long
The divisor of the rule that owns this substitution.Fields inherited from class com.ibm.icu.text.NFSubstitution
numberFormat, pos, ruleSet
-
Constructor Summary
ConstructorsConstructorDescriptionMultiplierSubstitution
(int pos, NFRule rule, NFRuleSet ruleSet, String description) Constructs a MultiplierSubstitution. -
Method Summary
Modifier and TypeMethodDescriptiondouble
calcUpperBound
(double oldUpperBound) Sets the upper bound down to the rule's divisor.double
composeRuleValue
(double newRuleValue, double oldRuleValue) Returns newRuleValue times the divisor.boolean
Augments the superclass's equals() function by comparing divisors.void
setDivisor
(int radix, short exponent) Sets the substitution's divisor based on the values passed in.(package private) char
The token character for a multiplier substitution is <.double
transformNumber
(double number) Divides the number by the rule's divisor and returns the quotient.long
transformNumber
(long number) Divides the number by the rule's divisor and returns the quotient.Methods inherited from class com.ibm.icu.text.NFSubstitution
doParse, doSubstitution, doSubstitution, getPos, hashCode, isModulusSubstitution, makeSubstitution, setDecimalFormatSymbols, toString
-
Field Details
-
divisor
long divisorThe divisor of the rule that owns this substitution.
-
-
Constructor Details
-
MultiplierSubstitution
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 textrule
- The rule that owns this substitutionruleSet
- The ruleSet this substitution uses to format its resultdescription
- 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 classNFSubstitution
- Parameters:
radix
- The radix of the divisor.exponent
- The exponent of the divisor.
-
equals
Augments the superclass's equals() function by comparing divisors.- Overrides:
equals
in classNFSubstitution
- 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 classNFSubstitution
- 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 classNFSubstitution
- 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 << substitution supersedes the base value of the rule that contains it.)- Specified by:
composeRuleValue
in classNFSubstitution
- Parameters:
newRuleValue
- The result of matching the substitutionoldRuleValue
- 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 classNFSubstitution
- Parameters:
oldUpperBound
- Ignored.- Returns:
- The rule's divisor.
-
tokenChar
char tokenChar()The token character for a multiplier substitution is <.- Specified by:
tokenChar
in classNFSubstitution
- Returns:
- '<'
-