Package com.ibm.icu.text
Class FractionalPartSubstitution
- java.lang.Object
-
- com.ibm.icu.text.NFSubstitution
-
- com.ibm.icu.text.FractionalPartSubstitution
-
class FractionalPartSubstitution extends NFSubstitution
A substitution that formats the fractional part of a number. This is represented by >> in a fraction rule.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
byDigits
true if this substitution should have the default "by digits" behavior, false otherwiseprivate boolean
useSpaces
true if we automatically insert spaces to separate names of digits set to false by '>>>' in fraction rules, used by Thai.-
Fields inherited from class com.ibm.icu.text.NFSubstitution
numberFormat, pos, ruleSet
-
-
Constructor Summary
Constructors Constructor Description FractionalPartSubstitution(int pos, NFRuleSet ruleSet, java.lang.String description)
Constructs a FractionalPartSubstitution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calcUpperBound(double oldUpperBound)
Not used.double
composeRuleValue(double newRuleValue, double oldRuleValue)
Returns the sum of the two partial parse results.java.lang.Number
doParse(java.lang.String text, java.text.ParsePosition parsePosition, double baseValue, double upperBound, boolean lenientParse, int nonNumericalExecutedRuleMask)
If in "by digits" mode, parses the string as if it were a string of individual digits; otherwise, uses the superclass function.void
doSubstitution(double number, java.lang.StringBuilder toInsertInto, int position, int recursionCount)
If in "by digits" mode, fills in the substitution one decimal digit at a time using the rule set containing this substitution.(package private) char
tokenChar()
The token character for a FractionalPartSubstitution is >.double
transformNumber(double number)
Returns the fractional part of the number.long
transformNumber(long number)
Returns the fractional part of the number, which will always be zero if it's a long.-
Methods inherited from class com.ibm.icu.text.NFSubstitution
doSubstitution, equals, getPos, hashCode, isModulusSubstitution, makeSubstitution, setDecimalFormatSymbols, setDivisor, toString
-
-
-
-
Field Detail
-
byDigits
private final boolean byDigits
true if this substitution should have the default "by digits" behavior, false otherwise
-
useSpaces
private final boolean useSpaces
true if we automatically insert spaces to separate names of digits set to false by '>>>' in fraction rules, used by Thai.
-
-
Constructor Detail
-
FractionalPartSubstitution
FractionalPartSubstitution(int pos, NFRuleSet ruleSet, java.lang.String description)
Constructs a FractionalPartSubstitution. This object keeps a flag telling whether it should format by digits or not. In addition, it marks the rule set it calls (if any) as a fraction rule set.
-
-
Method Detail
-
doSubstitution
public void doSubstitution(double number, java.lang.StringBuilder toInsertInto, int position, int recursionCount)
If in "by digits" mode, fills in the substitution one decimal digit at a time using the rule set containing this substitution. Otherwise, uses the superclass function.- Overrides:
doSubstitution
in classNFSubstitution
- Parameters:
number
- The number being formattedtoInsertInto
- The string to insert the result of formatting the substitution intoposition
- The position of the owning rule's rule text in toInsertInto
-
transformNumber
public long transformNumber(long number)
Returns the fractional part of the number, which will always be zero if it's a long.- Specified by:
transformNumber
in classNFSubstitution
- Parameters:
number
- The number being formatted- Returns:
- 0
-
transformNumber
public double transformNumber(double number)
Returns the fractional part of the number.- Specified by:
transformNumber
in classNFSubstitution
- Parameters:
number
- The number being formatted.- Returns:
- number - floor(number)
-
doParse
public java.lang.Number doParse(java.lang.String text, java.text.ParsePosition parsePosition, double baseValue, double upperBound, boolean lenientParse, int nonNumericalExecutedRuleMask)
If in "by digits" mode, parses the string as if it were a string of individual digits; otherwise, uses the superclass function.- Overrides:
doParse
in classNFSubstitution
- Parameters:
text
- The string to parseparsePosition
- Ignored on entry, but updated on exit to point to the first unmatched characterbaseValue
- The partial parse result prior to entering this functionupperBound
- Only consider rules with base values lower than this when filling in the substitutionlenientParse
- If true, try matching the text as numerals if matching as words doesn't work- Returns:
- If the match was successful, the current partial parse result; otherwise Long.valueOf(0). The result is either a Long or a Double.
-
composeRuleValue
public double composeRuleValue(double newRuleValue, double oldRuleValue)
Returns the sum of the two partial parse results.- Specified by:
composeRuleValue
in classNFSubstitution
- Parameters:
newRuleValue
- The result of parsing the substitutionoldRuleValue
- The partial parse result prior to calling this function- Returns:
- newRuleValue + oldRuleValue
-
calcUpperBound
public double calcUpperBound(double oldUpperBound)
Not used.- Specified by:
calcUpperBound
in classNFSubstitution
- Parameters:
oldUpperBound
- The current upper-bound setting. The new upper bound can't be any higher.
-
tokenChar
char tokenChar()
The token character for a FractionalPartSubstitution is >.- Specified by:
tokenChar
in classNFSubstitution
- Returns:
- '>'
-
-