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

pack-priv Class ModulusSubstitution

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

extends NFSubstitution
Class Inheritance

A substitution that divides the number being formatted by the its rule's divisor and formats the remainder. Represented by ">>" in a regular rule.

Field Summary

Modifier and TypeField and Description
pack-priv long
divisor

The divisor of the rule owning this substitution

private final NFRule
ruleToUse

If this is a >>> substitution, the rule to use to format the substitution value.

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

Constructor Summary

AccessConstructor and Description
pack-priv
ModulusSubstitution(int
The substitution's position in its rule's rule text
pos
,
NFRule
The rule that owns this substitution
rule
,
NFRule
The rule that precedes this substitution's rule in its rule set's rule list
rulePredecessor
,
NFRuleSet ruleSet, String
The description for this substitution
description
)

Constructs a ModulusSubstitution.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

The owning rule's divisor
calcUpperBound
(double
Ignored
oldUpperBound
)

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

Sets the upper bound down to the owning rule's divisor
public double
composeRuleValue(double
The result of parsing the substitution
newRuleValue
,
double
The base value of the rule containing the substitution
oldRuleValue
)

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

Returns the highest multiple of the rule's divisor that its less than or equal to oldRuleValue, plus newRuleValue.
public Number
doParse(String
The string to parse
text
,
ParsePosition
Ignored on entry, updated on exit to point to the first unmatched character.
parsePosition
,
double
The partial parse result prior to calling this routine.
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.

If this is a >>> substitution, match only against ruleToUse.
public void
doSubstitution(long
The number being formatted
number
,
StringBuilder
The string to insert the result of this substitution into
toInsertInto
,
int
The position of the rule text in toInsertInto
position
,
int recursionCount)

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

If this is a >>> substitution, use ruleToUse to fill in the substitution.
public void
doSubstitution(double
The number being formatted
number
,
StringBuilder
The string to insert the result of this substitution into
toInsertInto
,
int
The position of the rule text in toInsertInto
position
,
int recursionCount)

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

If this is a >>> substitution, use ruleToUse to fill in the substitution.
public boolean

Returns:

true if the two substitutions are functionally equivalent
equals
(Object
The other substitution
that
)

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

Augments the inherited equals() function by comparing divisors and ruleToUse.
public boolean
public void
setDivisor(int
The radix of the divisor.
radix
,
short
The exponent of the divisor.
exponent
)

Overrides com.ibm.icu.text.NFSubstitution.setDivisor.

Makes the substitution's divisor conform to that of the rule that owns it.
pack-priv char

Returns:

'>'
tokenChar
()

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

The token character of a ModulusSubstitution is >.
public long

Returns:

"number" mod divisor
transformNumber
(long
The number being formatted
number
)

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

Divides the number being formatted by the rule's divisor and returns the remainder.
public double

Returns:

"number" mod divisor
transformNumber
(double
The number being formatted
number
)

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

Divides the number being formatted by the rule's divisor and returns the remainder.
Inherited from com.ibm.icu.text.NFSubstitution:
getPoshashCodemakeSubstitutionsetDecimalFormatSymbolstoString

Field Detail

divisorback to summary
pack-priv long divisor

The divisor of the rule owning this substitution

ruleToUseback to summary
private final NFRule ruleToUse

If this is a >>> substitution, the rule to use to format the substitution value. Otherwise, null.

Constructor Detail

ModulusSubstitutionback to summary
pack-priv ModulusSubstitution(int pos, NFRule rule, NFRule rulePredecessor, NFRuleSet ruleSet, String description)

Constructs a ModulusSubstitution. In addition to the inherited members, a ModulusSubstitution keeps track of the divisor of the rule that owns it, and may also keep a reference to the rule that precedes the rule containing this substitution in the rule set's rule list.

Parameters
pos:int

The substitution's position in its rule's rule text

rule:NFRule

The rule that owns this substitution

rulePredecessor:NFRule

The rule that precedes this substitution's rule in its rule set's rule list

description:String

The description for this substitution

Method Detail

calcUpperBoundback to summary
public double calcUpperBound(double oldUpperBound)

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

Sets the upper bound down to the owning rule's divisor

Parameters
oldUpperBound:double

Ignored

Returns:double

The owning rule's divisor

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

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

Returns the highest multiple of the rule's divisor that its less than or equal to oldRuleValue, plus newRuleValue. (The result is the sum of the result of parsing the substitution plus the base value of the rule containing the substitution, but if the owning rule's base value isn't an even multiple of its divisor, we have to round it down to a multiple of the divisor, or we get unwanted digits in the result.)

Parameters
newRuleValue:double

The result of parsing the substitution

oldRuleValue:double

The base value of the rule containing the substitution

Returns:double

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

A third value derived from the other two, representing a partial parse result

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 this is a >>> substitution, match only against ruleToUse. Otherwise, use the superclass function.

Parameters
text:String

The string to parse

parsePosition:ParsePosition

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

baseValue:double

The partial parse result prior to calling this routine.

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(long number, StringBuilder toInsertInto, int position, int recursionCount)

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

If this is a >>> substitution, use ruleToUse to fill in the substitution. Otherwise, just use the superclass function.

Parameters
number:long

The number being formatted

toInsertInto:StringBuilder

The string to insert the result of this substitution into

position:int

The position of the rule text in toInsertInto

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

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

If this is a >>> substitution, use ruleToUse to fill in the substitution. Otherwise, just use the superclass function.

Parameters
number:double

The number being formatted

toInsertInto:StringBuilder

The string to insert the result of this substitution into

position:int

The position of the rule text in toInsertInto

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

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

Augments the inherited equals() function by comparing divisors and ruleToUse.

Parameters
that:Object

The other substitution

Returns:boolean

true if the two substitutions are functionally equivalent

Annotations
@Override
isModulusSubstitutionback to summary
public boolean isModulusSubstitution()

Overrides com.ibm.icu.text.NFSubstitution.isModulusSubstitution.

Returns true. This _is_ a ModulusSubstitution.

Returns:boolean

true

Annotations
@Override
setDivisorback to summary
public void setDivisor(int radix, short exponent)

Overrides com.ibm.icu.text.NFSubstitution.setDivisor.

Makes the substitution's divisor conform to that of the rule that owns it. Used when the divisor is determined after creation.

Parameters
radix:int

The radix of the divisor.

exponent:short

The exponent of the divisor.

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

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

The token character of a ModulusSubstitution is >.

Returns:char

'>'

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

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

Divides the number being formatted by the rule's divisor and returns the remainder.

Parameters
number:long

The number being formatted

Returns:long

"number" mod divisor

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

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

Divides the number being formatted by the rule's divisor and returns the remainder.

Parameters
number:double

The number being formatted

Returns:double

"number" mod divisor

Annotations
@Override