Additional top-level classes in compilation unit: SameValueSubstitution, MultiplierSubstitution, ModulusSubstitution, IntegralPartSubstitution, FractionalPartSubstitution, AbsoluteValueSubstitution, NumeratorSubstitution.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | |
| pack-priv final DecimalFormat | numberFormat
The DecimalFormat this substitution uses to format its result, or null. |
| pack-priv final int | pos
The substitution's position in the rule text of the rule that owns it |
| pack-priv final NFRuleSet | ruleSet
The rule set this substitution uses to format its result, or null. |
| Access | Constructor and Description |
|---|---|
| pack-priv | NFSubstitution(int
The substitution's position in the owning rule's rule
text pos, NFRuleSet The rule set that owns this substitution ruleSet, String The substitution descriptor (i.e., the text
inside the token characters) description)Base constructor for substitutions. |
| Modifier and Type | Method and Description |
|---|---|
| public abstract double | calcUpperBound(double
The current upper-bound setting. The new
upper bound can't be any higher. oldUpperBound)Calculates an upper bound when searching for a rule that matches this substitution. |
| public abstract double | Returns: A third value derived from the other two, representing a partial parse resultThe value produced by matching this substitution newRuleValue, double The value that was passed to the substitution
by the rule that owns it oldRuleValue)Derives a new value from the two values passed in. The two values are typically either the base values of two rules (the one containing the substitution and the one matching the substitution) or partial parse results derived in some other way. |
| public Number | Returns: 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.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)Parses a string using the rule set or DecimalFormat belonging to this substitution. |
| public void | doSubstitution(long
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)Performs a mathematical operation on the number, formats it using either ruleSet or decimalFormat, and inserts the result into toInsertInto. |
| 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)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 substitutions are functionally equivalentThe substitution to compare this one to that)Overrides java. |
| public final int | Returns: The substitution's position in the rule that owns it.Returns the substitution's position in the rule that owns it. |
| public int | |
| public boolean | Returns: true if this object is an instance of ModulusSubstitutionReturns true if this is a modulus substitution. |
| public static NFSubstitution | Returns: A new substitution constructed according to the descriptionThe substitution's position in the rule text of the
rule that owns it. pos, NFRule The rule containing this substitution rule, NFRule The rule preceding the one that contains
this substitution in the rule set's rule list (this is used
only for >>> substitutions). rulePredecessor, NFRuleSet The rule set containing the rule containing this
substitution ruleSet, RuleBasedNumberFormat The RuleBasedNumberFormat that ultimately owns
this substitution formatter, String The description to parse to build the substitution
(this is just the substring of the rule's description containing
the substitution token itself) description)Parses the description, creates the right kind of substitution, and initializes it based on the description. |
| public void | |
| public void | setDivisor(int
The radix of the divisor radix, short The exponent of the divisor exponent)Set's the substitution's divisor. |
| pack-priv abstract char | Returns: This substitution's token character.Returns the character used in the textual representation of substitutions of this type. |
| public String | Returns: A textual description of the substitution. This might not be identical to the description it was created from, but it'll produce the same result.Overrides java. |
| public abstract long | Returns: The result of performing the opreration on the numberThe number being formatted number)Subclasses override this function to perform some kind of mathematical operation on the number. |
| public abstract double | Returns: The result of performing the opreration on the numberThe number being formatted number)Subclasses override this function to perform some kind of mathematical operation on the number. |
| MAX_INT64_IN_DOUBLE | back to summary |
|---|---|
| private static final long MAX_INT64_IN_DOUBLE | |
| numberFormat | back to summary |
|---|---|
| pack-priv final DecimalFormat numberFormat The DecimalFormat this substitution uses to format its result, or null. (Either this or ruleSet has to be non-null.) | |
| pos | back to summary |
|---|---|
| pack-priv final int pos The substitution's position in the rule text of the rule that owns it | |
| ruleSet | back to summary |
|---|---|
| pack-priv final NFRuleSet ruleSet The rule set this substitution uses to format its result, or null. (Either this or numberFormat has to be non-null.) | |
| NFSubstitution | back to summary |
|---|---|
| pack-priv NFSubstitution(int pos, NFRuleSet ruleSet, String description) Base constructor for substitutions. This constructor sets up the fields which are common to all substitutions. | |
| calcUpperBound | back to summary |
|---|---|
| public abstract double calcUpperBound(double oldUpperBound) Calculates an upper bound when searching for a rule that matches this substitution. Rules with base values greater than or equal to upperBound are not considered.
| |
| composeRuleValue | back to summary |
|---|---|
| public abstract double composeRuleValue(double newRuleValue, double oldRuleValue) Derives a new value from the two values passed in. The two values are typically either the base values of two rules (the one containing the substitution and the one matching the substitution) or partial parse results derived in some other way. The operation is generally the inverse of the operation performed by transformNumber().
| |
| doParse | back to summary |
|---|---|
| public Number doParse(String text, ParsePosition parsePosition, double baseValue, double upperBound, boolean lenientParse, int nonNumericalExecutedRuleMask) Parses a string using the rule set or DecimalFormat belonging to this substitution. If there's a match, a mathematical operation (the inverse of the one used in formatting) is performed on the result of the parse and the value passed in and returned as the result. The parse position is updated to point to the first unmatched character in the string.
| |
| doSubstitution | back to summary |
|---|---|
| public void doSubstitution(long number, StringBuilder toInsertInto, int position, int recursionCount) Performs a mathematical operation on the number, formats it using either ruleSet or decimalFormat, and inserts the result into toInsertInto.
| |
| doSubstitution | back to summary |
|---|---|
| public void doSubstitution(double number, StringBuilder toInsertInto, int position, int recursionCount) Performs a mathematical operation on the number, formats it using either ruleSet or decimalFormat, and inserts the result into toInsertInto.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object that) Overrides java. Compares two substitutions for equality | |
| getPos | back to summary |
|---|---|
| public final int getPos() Returns the substitution's position in the rule that owns it.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isModulusSubstitution | back to summary |
|---|---|
| public boolean isModulusSubstitution() Returns true if this is a modulus substitution. (We didn't do this with instanceof partially because it causes source files to proliferate and partially because we have to port this to C++.)
| |
| makeSubstitution | back to summary |
|---|---|
| public static NFSubstitution makeSubstitution(int pos, NFRule rule, NFRule rulePredecessor, NFRuleSet ruleSet, RuleBasedNumberFormat formatter, String description) Parses the description, creates the right kind of substitution, and initializes it based on the description.
| |
| setDecimalFormatSymbols | back to summary |
|---|---|
| public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) | |
| setDivisor | back to summary |
|---|---|
| public void setDivisor(int radix, short exponent) Set's the substitution's divisor. Used by NFRule.setBaseValue(). A no-op for all substitutions except multiplier and modulus substitutions.
| |
| tokenChar | back to summary |
|---|---|
| pack-priv abstract char tokenChar() Returns the character used in the textual representation of substitutions of this type. Used by toString().
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a textual description of the substitution | |
| transformNumber | back to summary |
|---|---|
| public abstract long transformNumber(long number) Subclasses override this function to perform some kind of mathematical operation on the number. The result of this operation is formatted using the rule set or DecimalFormat that this substitution refers to, and the result is inserted into the result string.
| |
| transformNumber | back to summary |
|---|---|
| public abstract double transformNumber(double number) Subclasses override this function to perform some kind of mathematical operation on the number. The result of this operation is formatted using the rule set or DecimalFormat that this substitution refers to, and the result is inserted into the result string.
| |