| Modifier and Type | Field and Description |
|---|---|
| private long | baseValue
The rule's base value |
| private char | decimalPoint
If this is a fraction rule, this is the decimal point from DecimalFormatSymbols to match. |
| pack-priv static final int | DEFAULT_RULE
Special base value used to identify a default rule |
| private short | exponent
The rule's exponent (the radix raised to the power of the exponent equals the rule's divisor) |
| private final RuleBasedNumberFormat | formatter
The RuleBasedNumberFormat that owns this rule |
| pack-priv static final int | IMPROPER_FRACTION_RULE
Special base value used to identify an improper fraction (x.x) rule |
| pack-priv static final int | INFINITY_RULE
Special base value used to identify an infinity rule |
| pack-priv static final int | NAN_RULE
Special base value used to identify a not a number rule |
| pack-priv static final int | NEGATIVE_NUMBER_RULE
Special base value used to identify a negative-number rule |
| pack-priv static final int | PROPER_FRACTION_RULE
Special base value used to identify a proper fraction (0.x) rule |
| private int | radix
The rule's radix (the radix to the power of the exponent equals the rule's divisor) |
| private static final String[] | |
| private PluralFormat | rulePatternFormat
The rule's plural format when defined. |
| private String | ruleText
The rule's rule text. |
| private NFSubstitution | sub1
The rule's first substitution (the one with the lower offset into the rule text) |
| private NFSubstitution | sub2
The rule's second substitution (the one with the higher offset into the rule text) |
| pack-priv static final Long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | Returns: true if the string is empty of consists entirely of characters that the number formatter's collator says are ignorable at the primary-order level. false otherwise.The string to test. str)Checks to see whether a string consists entirely of ignorable characters. |
| public void | doFormat(long
The number being formatted number, StringBuilder The string where the resultant text should
be inserted toInsertInto, int The position in toInsertInto where the resultant text
should be inserted pos, int recursionCount)Formats the number, and inserts the resulting text into toInsertInto. |
| public void | doFormat(double
The number being formatted number, StringBuilder The string where the resultant text should
be inserted toInsertInto, int The position in toInsertInto where the resultant text
should be inserted pos, int recursionCount)Formats the number, and inserts the resulting text into toInsertInto. |
| public Number | Returns: If this rule matched the text, this is the rule's base value combined appropriately with the results of parsing the substitutions. If nothing matched, this is new Long(0) and the parse position is left unchanged. The result will be an instance of Long if the result is an integer and Double otherwise. The result is never null.The string being parsed text, ParsePosition On entry, the value is ignored and assumed to
be 0. On exit, this has been updated with the position of the first
character not consumed by matching the text against this rule
(if this rule doesn't match the text at all, the parse position
if left unchanged (presumably at 0) and the function returns
new Long(0)). parsePosition, boolean True if this rule is contained within a
fraction rule set. This is only used if the rule has no
substitutions. isFractionRule, double upperBound, int nonNumericalExecutedRuleMask)Attempts to parse the string with this rule. |
| public boolean | Returns: True if the two rules are functionally equivalentThe rule to compare this one against that)Overrides java. |
| private short | |
| private NFSubstitution | Returns: The newly-created substitution. This is never null; if the rule text doesn't contain any substitution tokens, this will be a NullSubstitution.The rule set containing this rule owner, NFRule The rule preceding this one in the rule set's
rule list predecessor)Searches the rule's rule text for the first substitution token, creates a substitution based on it, and removes the token from the rule's rule text. |
| private void | extractSubstitutions(NFRuleSet
The rule set containing this rule owner, String The rule text ruleText, NFRule The rule preceding this one in "owners" rule list predecessor)Searches the rule's rule text for the substitution tokens, creates the substitutions, and removes the substitution tokens from the rule's rule text. |
| private int[] | Returns: A two-element array of ints. Element 0 is the position of the match, or -1 if there was no match. Element 1 is the number of characters in "str" that matched (which isn't necessarily the same as the length of "key")The string to search str, String The string to search "str" for key, PluralFormat pluralFormatKey, int The index into "str" where the search is to
begin startingAt)Searches a string for another string. |
| public final long | |
| public final char | |
| public long | Returns: The rule's divisorReturns the rule's divisor (the value that controls the behavior of its substitutions) |
| public int | |
| private static int | Returns: The index of the first match in the rule's rule text (i.e., the first substring in the rule's rule text that matches _any_ of the strings in "strings"). If none of the strings in "strings" is found in the rule's rule text, returns -1.Searches the rule's rule text for any of the specified strings. |
| public static void | makeRules(String
The description of the rule(s). description, NFRuleSet The rule set containing the new rule(s). owner, NFRule The rule that precedes the new one(s) in "owner"'s
rule list predecessor, RuleBasedNumberFormat The RuleBasedNumberFormat that owns the
rule set that owns the new rule(s) ownersOwner, List<NFRule> One or more instances of NFRule are added and returned here returnList)Creates one or more rules based on the description passed in. |
| private Number | Returns: If there's a match, this is the result of composing baseValue with the result of matching the substitution. Otherwise, this is new Long(0). It's never null. If the result is an integer, this will be an instance of Long; otherwise, it's an instance of Double.The string being parsed text, int The position in "text" where we should start looking
for "delimiter". startPos, double A partial parse result (often the rule's base value),
which is combined with the result from matching the substitution baseVal, String The string to search "text" for. delimiter, PluralFormat pluralFormatDelimiter, ParsePosition Ignored and presumed to be 0 on entry. If there's a match,
on exit this will point to the first unmatched character. pp, NFSubstitution If we find "delimiter" in "text", this substitution is used
to match the text between the beginning of the string and the
position of "delimiter." (If "delimiter" is the empty string, then
this function just matches against this substitution and updates
everything accordingly.) sub, double When matching the substitution, it will only
consider rules with base values lower than this value. upperBound, int nonNumericalExecutedRuleMask)Used by parse() to match a substitution and any following text. |
| private String | Returns: If "description" included a rule descriptor, this is "description" with the descriptor and any trailing whitespace stripped off. Otherwise; it's "descriptor" unchanged.The rule's description description)This function parses the rule's rule descriptor (i.e., the base value and/or other tokens that precede the rule's rule text in the description) and sets the rule's base value, radix, and exponent according to the descriptor. |
| pack-priv static long | Returns: radix ** exponentThe base base, short The exponent exponent)This is an equivalent to Math.pow that accurately works on 64-bit numbers |
| private int | Returns: If "prefix" is found at the beginning of "str", this is the number of characters in "str" that were matched (this isn't necessarily the same as the length of "prefix" when matching text with a collator). If there's no match, this is 0.The string being tested str, String The text we're hoping to see at the beginning
of "str" prefix)Used by stripPrefix() to match characters. |
| pack-priv final void | setBaseValue(long
The new base value for the rule. newBaseValue)Sets the rule's base value, and causes the radix and exponent to be recalculated. |
| public void | |
| public boolean | Returns: True if the rule set should use the rule that precedes this one in its list; false if it should use this ruleThe number being formatted number)Used by the owning rule set to determine whether to invoke the rollback rule (i.e., whether this rule or the one that precedes it in the rule set's list should be used to format the number) |
| private String | Returns: If things match, this is the unparsed part of "text"; if they didn't match, this is "text".The string being parsed text, String The text to match against prefix, ParsePosition On entry, ignored and assumed to be 0. On exit, points
to the first unmatched character (assuming the whole prefix matched),
or is unchanged (if the whole prefix didn't match). pp)This function is used by parse() to match the text being parsed against a possible prefix string. |
| public String | Returns: A textual description of the ruleOverrides java. |
| baseValue | back to summary |
|---|---|
| private long baseValue The rule's base value | |
| decimalPoint | back to summary |
|---|---|
| private char decimalPoint If this is a fraction rule, this is the decimal point from DecimalFormatSymbols to match. | |
| DEFAULT_RULE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_RULE Special base value used to identify a default rule | |
| exponent | back to summary |
|---|---|
| private short exponent The rule's exponent (the radix raised to the power of the exponent equals the rule's divisor) | |
| formatter | back to summary |
|---|---|
| private final RuleBasedNumberFormat formatter The RuleBasedNumberFormat that owns this rule | |
| IMPROPER_FRACTION_RULE | back to summary |
|---|---|
| pack-priv static final int IMPROPER_FRACTION_RULE Special base value used to identify an improper fraction (x.x) rule | |
| INFINITY_RULE | back to summary |
|---|---|
| pack-priv static final int INFINITY_RULE Special base value used to identify an infinity rule | |
| NAN_RULE | back to summary |
|---|---|
| pack-priv static final int NAN_RULE Special base value used to identify a not a number rule | |
| NEGATIVE_NUMBER_RULE | back to summary |
|---|---|
| pack-priv static final int NEGATIVE_NUMBER_RULE Special base value used to identify a negative-number rule | |
| PROPER_FRACTION_RULE | back to summary |
|---|---|
| pack-priv static final int PROPER_FRACTION_RULE Special base value used to identify a proper fraction (0.x) rule | |
| radix | back to summary |
|---|---|
| private int radix The rule's radix (the radix to the power of the exponent equals the rule's divisor) | |
| RULE_PREFIXES | back to summary |
|---|---|
| private static final String[] RULE_PREFIXES | |
| rulePatternFormat | back to summary |
|---|---|
| private PluralFormat rulePatternFormat The rule's plural format when defined. This is not a substitution because it only works on the current baseValue. It's normally not used due to the overhead. | |
| ruleText | back to summary |
|---|---|
| private String ruleText The rule's rule text. When formatting a number, the rule's text is inserted into the result string, and then the text from any substitutions is inserted into the result string | |
| sub1 | back to summary |
|---|---|
| private NFSubstitution sub1 The rule's first substitution (the one with the lower offset into the rule text) | |
| sub2 | back to summary |
|---|---|
| private NFSubstitution sub2 The rule's second substitution (the one with the higher offset into the rule text) | |
| ZERO | back to summary |
|---|---|
| pack-priv static final Long ZERO | |
| NFRule | back to summary |
|---|---|
| public NFRule(RuleBasedNumberFormat formatter, String ruleText) Nominal constructor for NFRule. Most of the work of constructing an NFRule is actually performed by makeRules(). | |
| allIgnorable | back to summary |
|---|---|
| private boolean allIgnorable(String str) Checks to see whether a string consists entirely of ignorable characters.
| |
| doFormat | back to summary |
|---|---|
| public void doFormat(long number, StringBuilder toInsertInto, int pos, int recursionCount) Formats the number, and inserts the resulting text into toInsertInto.
| |
| doFormat | back to summary |
|---|---|
| public void doFormat(double number, StringBuilder toInsertInto, int pos, int recursionCount) Formats the number, and inserts the resulting text into toInsertInto.
| |
| doParse | back to summary |
|---|---|
| public Number doParse(String text, ParsePosition parsePosition, boolean isFractionRule, double upperBound, int nonNumericalExecutedRuleMask) Attempts to parse the string with this rule.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object that) Overrides java. Tests two rules for equality. | |
| expectedExponent | back to summary |
|---|---|
| private short expectedExponent() This calculates the rule's exponent based on its radix and base value. This will be the highest power the radix can be raised to and still produce a result less than or equal to the base value. | |
| extractSubstitution | back to summary |
|---|---|
| private NFSubstitution extractSubstitution(NFRuleSet owner, NFRule predecessor) Searches the rule's rule text for the first substitution token, creates a substitution based on it, and removes the token from the rule's rule text.
| |
| extractSubstitutions | back to summary |
|---|---|
| private void extractSubstitutions(NFRuleSet owner, String ruleText, NFRule predecessor) Searches the rule's rule text for the substitution tokens, creates the substitutions, and removes the substitution tokens from the rule's rule text. | |
| findText | back to summary |
|---|---|
| private int[] findText(String str, String key, PluralFormat pluralFormatKey, int startingAt) Searches a string for another string. If lenient parsing is off, this just calls indexOf(). If lenient parsing is on, this function uses CollationElementIterator to match characters, and only primary-order differences are significant in determining whether there's a match.
| |
| getBaseValue | back to summary |
|---|---|
| public final long getBaseValue() Returns the rule's base value
| |
| getDecimalPoint | back to summary |
|---|---|
| public final char getDecimalPoint() Returns the rule's base value
| |
| getDivisor | back to summary |
|---|---|
| public long getDivisor() Returns the rule's divisor (the value that controls the behavior of its substitutions)
| |
| 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
| |
| indexOfAnyRulePrefix | back to summary |
|---|---|
| private static int indexOfAnyRulePrefix(String ruleText) Searches the rule's rule text for any of the specified strings.
| |
| makeRules | back to summary |
|---|---|
| public static void makeRules(String description, NFRuleSet owner, NFRule predecessor, RuleBasedNumberFormat ownersOwner, List<NFRule> returnList) Creates one or more rules based on the description passed in.
| |
| matchToDelimiter | back to summary |
|---|---|
| private Number matchToDelimiter(String text, int startPos, double baseVal, String delimiter, PluralFormat pluralFormatDelimiter, ParsePosition pp, NFSubstitution sub, double upperBound, int nonNumericalExecutedRuleMask) Used by parse() to match a substitution and any following text. "text" is searched for instances of "delimiter". For each instance of delimiter, the intervening text is tested to see whether it matches the substitution. The longest match wins.
| |
| parseRuleDescriptor | back to summary |
|---|---|
| private String parseRuleDescriptor(String description) This function parses the rule's rule descriptor (i.e., the base value and/or other tokens that precede the rule's rule text in the description) and sets the rule's base value, radix, and exponent according to the descriptor. (If the description doesn't include a rule descriptor, then this function sets everything to default values and the rule set sets the rule's real base value). | |
| power | back to summary |
|---|---|
| pack-priv static long power(long base, short exponent) This is an equivalent to Math.pow that accurately works on 64-bit numbers
| |
| prefixLength | back to summary |
|---|---|
| private int prefixLength(String str, String prefix) Used by stripPrefix() to match characters. If lenient parse mode is off, this just calls startsWith(). If lenient parse mode is on, this function uses CollationElementIterators to match characters in the strings (only primary-order differences are significant in determining whether there's a match).
| |
| setBaseValue | back to summary |
|---|---|
| pack-priv final void setBaseValue(long newBaseValue) Sets the rule's base value, and causes the radix and exponent to be recalculated. This is used during construction when we don't know the rule's base value until after it's been constructed. It should not be used at any other time.
| |
| setDecimalFormatSymbols | back to summary |
|---|---|
| public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) | |
| shouldRollBack | back to summary |
|---|---|
| public boolean shouldRollBack(long number) Used by the owning rule set to determine whether to invoke the rollback rule (i.e., whether this rule or the one that precedes it in the rule set's list should be used to format the number)
| |
| stripPrefix | back to summary |
|---|---|
| private String stripPrefix(String text, String prefix, ParsePosition pp) This function is used by parse() to match the text being parsed against a possible prefix string. This function matches characters from the beginning of the string being parsed to characters from the prospective prefix. If they match, pp is updated to the first character not matched, and the result is the unparsed part of the string. If they don't match, the whole string is returned, and pp is left unchanged.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a textual representation of the rule. This won't necessarily be the same as the description that this rule was created with, but it will produce the same result. | |