Top Description Fields Constructors Methods
com.ibm.icu.text

pack-priv Class FractionalPartSubstitution

Located in compilation unit of com.ibm.icu.text.NFSubstitution.

extends NFSubstitution
Class Inheritance

A substitution that formats the fractional part of a number. This is represented by >> in a fraction rule.

Field Summary

Modifier and TypeField and Description
private final boolean
byDigits

true if this substitution should have the default "by digits" behavior, false otherwise

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.

Inherited from com.ibm.icu.text.NFSubstitution:
numberFormatposruleSet

Constructor Summary

AccessConstructor and Description
pack-priv
FractionalPartSubstitution(int pos, NFRuleSet ruleSet, String description)

Constructs a FractionalPartSubstitution.

Method Summary

Modifier and TypeMethod and Description
public double
calcUpperBound(double
The current upper-bound setting. The new upper bound can't be any higher.
oldUpperBound
)

Implements abstract com.ibm.icu.text.NFSubstitution.calcUpperBound.

Not used.
public double

Returns:

newRuleValue + oldRuleValue
composeRuleValue
(double
The result of parsing the substitution
newRuleValue
,
double
The partial parse result prior to calling this function
oldRuleValue
)

Implements abstract com.ibm.icu.text.NFSubstitution.composeRuleValue.

Returns the sum of the two partial parse results.
public Number

Returns:

If the match was successful, the current partial parse result; otherwise new Long(0). The result is either a Long or a Double.
doParse
(String
The string to parse
text
,
ParsePosition
Ignored on entry, but updated on exit to point to the first unmatched character
parsePosition
,
double
The partial parse result prior to entering this function
baseValue
,
double
Only consider rules with base values lower than this when filling in the substitution
upperBound
,
boolean
If true, try matching the text as numerals if matching as words doesn't work
lenientParse
,
int nonNumericalExecutedRuleMask)

Overrides com.ibm.icu.text.NFSubstitution.doParse.

If in "by digits" mode, parses the string as if it were a string of individual digits; otherwise, uses the superclass function.
public void
doSubstitution(double
The number being formatted
number
,
StringBuilder
The string to insert the result of formatting the substitution into
toInsertInto
,
int
The position of the owning rule's rule text in toInsertInto
position
,
int recursionCount)

Overrides com.ibm.icu.text.NFSubstitution.doSubstitution.

If in "by digits" mode, fills in the substitution one decimal digit at a time using the rule set containing this substitution.
pack-priv char

Returns:

'>'
tokenChar
()

Implements abstract com.ibm.icu.text.NFSubstitution.tokenChar.

The token character for a FractionalPartSubstitution is >.
public long

Returns:

0
transformNumber
(long
The number being formatted
number
)

Implements abstract com.ibm.icu.text.NFSubstitution.transformNumber.

Returns the fractional part of the number, which will always be zero if it's a long.
public double

Returns:

number - floor(number)
transformNumber
(double
The number being formatted.
number
)

Implements abstract com.ibm.icu.text.NFSubstitution.transformNumber.

Returns the fractional part of the number.
Inherited from com.ibm.icu.text.NFSubstitution:
doSubstitutionequalsgetPoshashCodeisModulusSubstitutionmakeSubstitutionsetDecimalFormatSymbolssetDivisortoString

Field Detail

byDigitsback to summary
private final boolean byDigits

true if this substitution should have the default "by digits" behavior, false otherwise

useSpacesback to summary
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

FractionalPartSubstitutionback to summary
pack-priv FractionalPartSubstitution(int pos, NFRuleSet ruleSet, 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

calcUpperBoundback to summary
public double calcUpperBound(double oldUpperBound)

Implements abstract com.ibm.icu.text.NFSubstitution.calcUpperBound.

Not used.

Parameters
oldUpperBound:double

Doc from com.ibm.icu.text.NFSubstitution.calcUpperBound.

The current upper-bound setting. The new upper bound can't be any higher.

Annotations
@Override
composeRuleValueback to summary
public double composeRuleValue(double newRuleValue, double oldRuleValue)

Implements abstract com.ibm.icu.text.NFSubstitution.composeRuleValue.

Returns the sum of the two partial parse results.

Parameters
newRuleValue:double

The result of parsing the substitution

oldRuleValue:double

The partial parse result prior to calling this function

Returns:double

newRuleValue + oldRuleValue

Annotations
@Override
doParseback to summary
public Number doParse(String text, ParsePosition parsePosition, double baseValue, double upperBound, boolean lenientParse, int nonNumericalExecutedRuleMask)

Overrides com.ibm.icu.text.NFSubstitution.doParse.

If in "by digits" mode, parses the string as if it were a string of individual digits; otherwise, uses the superclass function.

Parameters
text:String

The string to parse

parsePosition:ParsePosition

Ignored on entry, but updated on exit to point to the first unmatched character

baseValue:double

The partial parse result prior to entering this function

upperBound:double

Only consider rules with base values lower than this when filling in the substitution

lenientParse:boolean

If true, try matching the text as numerals if matching as words doesn't work

Returns:Number

If the match was successful, the current partial parse result; otherwise new Long(0). The result is either a Long or a Double.

Annotations
@Override
doSubstitutionback to summary
public void doSubstitution(double number, StringBuilder toInsertInto, int position, int recursionCount)

Overrides com.ibm.icu.text.NFSubstitution.doSubstitution.

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.

Parameters
number:double

The number being formatted

toInsertInto:StringBuilder

The string to insert the result of formatting the substitution into

position:int

The position of the owning rule's rule text in toInsertInto

Annotations
@Override
tokenCharback to summary
pack-priv char tokenChar()

Implements abstract com.ibm.icu.text.NFSubstitution.tokenChar.

The token character for a FractionalPartSubstitution is >.

Returns:char

'>'

Annotations
@Override
transformNumberback to summary
public long transformNumber(long number)

Implements abstract com.ibm.icu.text.NFSubstitution.transformNumber.

Returns the fractional part of the number, which will always be zero if it's a long.

Parameters
number:long

The number being formatted

Returns:long

0

Annotations
@Override
transformNumberback to summary
public double transformNumber(double number)

Implements abstract com.ibm.icu.text.NFSubstitution.transformNumber.

Returns the fractional part of the number.

Parameters
number:double

The number being formatted.

Returns:double

number - floor(number)

Annotations
@Override