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

pack-priv Class NumeratorSubstitution

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

extends NFSubstitution
Class Inheritance

A substitution that multiplies the number being formatted (which is between 0 and 1) by the base value of the rule that owns it and formats the result. It is represented by << in the rules in a fraction rule set.

Field Summary

Modifier and TypeField and Description
private final double
denominator

The denominator of the fraction we're finding the numerator for.

private final boolean
withZeros

True if we format leading zeros (this is a hack for Hebrew spellout)

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

Constructor Summary

AccessConstructor and Description
pack-priv
NumeratorSubstitution(int pos, double denominator, NFRuleSet ruleSet, String description)

Constructs a NumeratorSubstitution.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

The base value of the rule owning this substitution
calcUpperBound
(double
Ignored
oldUpperBound
)

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

Sets the upper bound down to this rule's base value
public double

Returns:

newRuleValue / oldRuleValue
composeRuleValue
(double
The result of parsing the substitution
newRuleValue
,
double
The owning rule's base value
oldRuleValue
)

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

Divides the result of parsing the substitution by the partial parse result.
public Number
doParse(String
The string to parse
text
,
ParsePosition
On entry, ignored, but assumed to be 0. On exit, this is updated to point to the first unmatched character (or 0 if the substitution didn't match)
parsePosition
,
double
A partial parse result that should be combined with the result of this parse
baseValue
,
double
When searching the rule set for a rule matching the string passed in, only rules with base values lower than this are considered
upperBound
,
boolean
If true and matching against rules fails, the substitution will also try matching the text against numerals using a default-constructed NumberFormat. If false, no extra work is done. (This value is false whenever the formatter isn't in lenient-parse mode, but is also false under some conditions even when the formatter _is_ in lenient-parse mode.)
lenientParse
,
int nonNumericalExecutedRuleMask)

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

Dispatches to the inherited version of this function, but makes sure that lenientParse is off.
public void
doSubstitution(double
The number being formatted.
number
,
StringBuilder
The string we insert the result into
toInsertInto
,
int
The position in toInsertInto where the owning rule's rule text begins (this value is added to this substitution's position to determine exactly where to insert the new text)
position
,
int recursionCount)

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

Performs a mathematical operation on the number, formats it using either ruleSet or decimalFormat, and inserts the result into toInsertInto.
public boolean

Returns:

true if the two objects are functionally equivalent
equals
(Object
The other NumeratorSubstitution
that
)

Overrides com.ibm.icu.text.NFSubstitution.equals.

Tests two NumeratorSubstitutions for equality
pack-priv static String
fixdesc(String description)

pack-priv char

Returns:

'<'
tokenChar
()

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

The token character for a NumeratorSubstitution is <
public long

Returns:

number * denominator
transformNumber
(long
The number being formatted
number
)

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

Returns the number being formatted times the denominator.
public double

Returns:

number * denominator
transformNumber
(double
The number being formatted
number
)

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

Returns the number being formatted times the denominator.
Inherited from com.ibm.icu.text.NFSubstitution:
doSubstitutiongetPoshashCodeisModulusSubstitutionmakeSubstitutionsetDecimalFormatSymbolssetDivisortoString

Field Detail

denominatorback to summary
private final double denominator

The denominator of the fraction we're finding the numerator for. (The base value of the rule that owns this substitution.)

withZerosback to summary
private final boolean withZeros

True if we format leading zeros (this is a hack for Hebrew spellout)

Constructor Detail

NumeratorSubstitutionback to summary
pack-priv NumeratorSubstitution(int pos, double denominator, NFRuleSet ruleSet, String description)

Constructs a NumeratorSubstitution. In addition to the inherited fields, a NumeratorSubstitution keeps track of a denominator, which is merely the base value of the rule that owns it.

Method Detail

calcUpperBoundback to summary
public double calcUpperBound(double oldUpperBound)

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

Sets the upper bound down to this rule's base value

Parameters
oldUpperBound:double

Ignored

Returns:double

The base value of the rule owning this substitution

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

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

Divides the result of parsing the substitution by the partial parse result.

Parameters
newRuleValue:double

The result of parsing the substitution

oldRuleValue:double

The owning rule's base value

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.

Dispatches to the inherited version of this function, but makes sure that lenientParse is off.

Parameters
text:String

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

The string to parse

parsePosition:ParsePosition

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

On entry, ignored, but assumed to be 0. On exit, this is updated to point to the first unmatched character (or 0 if the substitution didn't match)

baseValue:double

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

A partial parse result that should be combined with the result of this parse

upperBound:double

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

When searching the rule set for a rule matching the string passed in, only rules with base values lower than this are considered

lenientParse:boolean

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

If true and matching against rules fails, the substitution will also try matching the text against numerals using a default-constructed NumberFormat. If false, no extra work is done. (This value is false whenever the formatter isn't in lenient-parse mode, but is also false under some conditions even when the formatter _is_ in lenient-parse mode.)

Returns:Number

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

If there's a match, this is the result of composing baseValue with whatever was returned from matching the characters. This will be either a Long or a Double. If there's no match this is new Long(0) (not null), and parsePosition is left unchanged.

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

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

Performs a mathematical operation on the number, formats it using either ruleSet or decimalFormat, and inserts the result into toInsertInto.

Parameters
number:double

The number being formatted.

toInsertInto:StringBuilder

The string we insert the result into

position:int

The position in toInsertInto where the owning rule's rule text begins (this value is added to this substitution's position to determine exactly where to insert the new text)

Annotations
@Override
equalsback to summary
public boolean equals(Object that)

Overrides com.ibm.icu.text.NFSubstitution.equals.

Tests two NumeratorSubstitutions for equality

Parameters
that:Object

The other NumeratorSubstitution

Returns:boolean

true if the two objects are functionally equivalent

Annotations
@Override
fixdescback to summary
pack-priv static String fixdesc(String description)
tokenCharback to summary
pack-priv char tokenChar()

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

The token character for a NumeratorSubstitution is <

Returns:char

'<'

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

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

Returns the number being formatted times the denominator.

Parameters
number:long

The number being formatted

Returns:long

number * denominator

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

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

Returns the number being formatted times the denominator.

Parameters
number:double

The number being formatted

Returns:double

number * denominator

Annotations
@Override