| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv LinkedList | fractionRules
These are a pile of fraction rules in declared order. |
| pack-priv static final int | |
| pack-priv static final int | |
| private boolean | isFractionRuleSet
True if the rule set is a fraction rule set. |
| private final boolean | isParseable
True if the rule set is parseable. |
| private final String | name
The rule set's name |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv final NFRule[] | nonNumericalRules
The rule set's non-numerical rules like negative, fractions, infinity and NaN |
| pack-priv final RuleBasedNumberFormat | owner
The RuleBasedNumberFormat that owns this rule |
| pack-priv static final int | |
| private static final int | RECURSION_LIMIT
Limit of recursion. |
| private NFRule[] | rules
The rule set's regular rules |
| Access | Constructor and Description |
|---|---|
| public | NFRuleSet(RuleBasedNumberFormat
The formatter that owns this rule set owner, String[] An array of Strings representing rule set
descriptions. On exit, this rule set's entry in the array will
have been stripped of its rule set name and any trailing whitespace. descriptions, int The index into "descriptions" of the description
for the rule to be constructed index)Constructs a rule set. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the two rule sets are functionally equivalent.The other rule set that)Overrides java. |
| private NFRule | Returns: The rule to use to format this numberThe number being formatted (which will always be
a number between 0 and 1) number)If this rule is a fraction rule set, this function is used by findRule() to select the most appropriate rule for formatting the number. |
| private NFRule | Returns: The rule to use to format this numberThe number being formatted number)If the value passed to findRule() is a positive integer, findRule() uses this function to select the appropriate rule. |
| pack-priv NFRule | Returns: The rule that should be used to format itThe number being formatted. number)Selects an appropriate rule for formatting the number. |
| public void | format(long
The number being formatted number, StringBuilder The string where the result is to be placed toInsertInto, int The position in toInsertInto where the result of
this operation is to be inserted pos, int recursionCount)Formats a long. |
| public void | format(double
The number being formatted number, StringBuilder The string where the result is to be placed toInsertInto, int The position in toInsertInto where the result of
this operation is to be inserted pos, int recursionCount)Formats a double. |
| public String | |
| public int | |
| public boolean | Returns: true if this rule is a fraction rule set; false if it isn'tSays whether this rule set is a fraction rule set. |
| public boolean | Returns: true if the rule set can be used for parsing.Return true if the rule set can be used for parsing. |
| public boolean | |
| private static long | |
| public void | |
| public Number | Returns: The numerical result of parsing this string. This will be the matching rule's base value, composed appropriately with the results of matching any of its substitutions. The object will be an instance of Long if it's an integral value; otherwise, it will be an instance of Double. This function always returns a valid object: If nothing matched the input string at all, this function returns new Long(0), and the parse position is left unchanged.The string to parse text, ParsePosition The initial position is ignored and assumed
to be 0. On exit, this object has been updated to point to the
first character position this rule set didn't consume. parsePosition, double Limits the rules that can be allowed to match.
Only rules whose base values are strictly less than upperBound
are considered. upperBound, int nonNumericalExecutedRuleMask)Parses a string. |
| public void | parseRules(String
The textual description of this rule set description)Construct the subordinate data structures used by this object. |
| private void | setBestFractionRule(int
The index into nonNumericalRules originalIndex, NFRule The new rule to consider newRule, boolean Should the new rule be added to fractionRules. rememberRule)Determine the best fraction rule to use. |
| public void | |
| pack-priv void | |
| public String | Returns: A textual representation of a rule set. This won't necessarily be the same description that the rule set was constructed with, but it will produce the same results.Overrides java. |
| DEFAULT_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int DEFAULT_RULE_INDEX x.0 | |
| fractionRules | back to summary |
|---|---|
| pack-priv LinkedList<NFRule> fractionRules These are a pile of fraction rules in declared order. They may have alternate ways to represent fractions. | |
| IMPROPER_FRACTION_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int IMPROPER_FRACTION_RULE_INDEX x.x | |
| INFINITY_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int INFINITY_RULE_INDEX Inf | |
| isFractionRuleSet | back to summary |
|---|---|
| private boolean isFractionRuleSet True if the rule set is a fraction rule set. A fraction rule set is a rule set that is used to format the fractional part of a number. It is called from a >> substitution in another rule set's fraction rule, and is only called upon to format values between 0 and 1. A fraction rule set has different rule-selection behavior than a regular rule set. | |
| isParseable | back to summary |
|---|---|
| private final boolean isParseable True if the rule set is parseable. | |
| name | back to summary |
|---|---|
| private final String name The rule set's name | |
| NAN_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int NAN_RULE_INDEX NaN | |
| NEGATIVE_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int NEGATIVE_RULE_INDEX -x | |
| nonNumericalRules | back to summary |
|---|---|
| pack-priv final NFRule[] nonNumericalRules The rule set's non-numerical rules like negative, fractions, infinity and NaN | |
| owner | back to summary |
|---|---|
| pack-priv final RuleBasedNumberFormat owner The RuleBasedNumberFormat that owns this rule | |
| PROPER_FRACTION_RULE_INDEX | back to summary |
|---|---|
| pack-priv static final int PROPER_FRACTION_RULE_INDEX 0.x | |
| RECURSION_LIMIT | back to summary |
|---|---|
| private static final int RECURSION_LIMIT Limit of recursion. It's about a 64 bit number formatted in base 2. | |
| rules | back to summary |
|---|---|
| private NFRule[] rules The rule set's regular rules | |
| NFRuleSet | back to summary |
|---|---|
| public NFRuleSet(RuleBasedNumberFormat owner, String[] descriptions, int index) throws IllegalArgumentException Constructs a rule set.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object that) Overrides java. Compares two rule sets for equality. | |
| findFractionRuleSetRule | back to summary |
|---|---|
| private NFRule findFractionRuleSetRule(double number) If this rule is a fraction rule set, this function is used by findRule() to select the most appropriate rule for formatting the number. Basically, the base value of each rule in the rule set is treated as the denominator of a fraction. Whichever denominator can produce the fraction closest in value to the number passed in is the result. If there's a tie, the earlier one in the list wins. (If there are two rules in a row with the same base value, the first one is used when the numerator of the fraction would be 1, and the second rule is used the rest of the time.
| |
| findNormalRule | back to summary |
|---|---|
| private NFRule findNormalRule(long number) If the value passed to findRule() is a positive integer, findRule() uses this function to select the appropriate rule. The result will generally be the rule with the highest base value less than or equal to the number. There is one exception to this: If that rule has two substitutions and a base value that is not an even multiple of its divisor, and the number itself IS an even multiple of the rule's divisor, then the result will be the rule that preceded the original result in the rule list. (This behavior is known as the "rollback rule", and is used to handle optional text: a rule with optional text is represented internally as two rules, and the rollback rule selects appropriate between them. This avoids things like "two hundred zero".)
| |
| findRule | back to summary |
|---|---|
| pack-priv NFRule findRule(double number) Selects an appropriate rule for formatting the number.
| |
| format | back to summary |
|---|---|
| public void format(long number, StringBuilder toInsertInto, int pos, int recursionCount) Formats a long. Selects an appropriate rule and dispatches control to it.
| |
| format | back to summary |
|---|---|
| public void format(double number, StringBuilder toInsertInto, int pos, int recursionCount) Formats a double. Selects an appropriate rule and dispatches control to it.
| |
| getName | back to summary |
|---|---|
| public String getName() Returns the rule set's name
| |
| 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
| |
| isFractionSet | back to summary |
|---|---|
| public boolean isFractionSet() Says whether this rule set is a fraction rule set.
| |
| isParseable | back to summary |
|---|---|
| public boolean isParseable() Return true if the rule set can be used for parsing.
| |
| isPublic | back to summary |
|---|---|
| public boolean isPublic() Return true if the rule set is public.
| |
| lcm | back to summary |
|---|---|
| private static long lcm(long x, long y) Calculates the least common multiple of x and y. | |
| makeIntoFractionRuleSet | back to summary |
|---|---|
| public void makeIntoFractionRuleSet() Flags this rule set as a fraction rule set. This function is called during the construction process once we know this rule set is a fraction rule set. We don't know a rule set is a fraction rule set until we see it used somewhere. This function is not ad must not be called at any time other than during construction of a RuleBasedNumberFormat. | |
| parse | back to summary |
|---|---|
| public Number parse(String text, ParsePosition parsePosition, double upperBound, int nonNumericalExecutedRuleMask) Parses a string. Matches the string to be parsed against each of its rules (with a base value less than upperBound) and returns the value produced by the rule that matched the most characters in the source string.
| |
| parseRules | back to summary |
|---|---|
| public void parseRules(String description) Construct the subordinate data structures used by this object. This function is called by the RuleBasedNumberFormat constructor after all the rule sets have been created to actually parse the description and build rules from it. Since any rule set can refer to any other rule set, we have to have created all of them before we can create anything else.
| |
| setBestFractionRule | back to summary |
|---|---|
| private void setBestFractionRule(int originalIndex, NFRule newRule, boolean rememberRule) Determine the best fraction rule to use. Rules matching the decimal point from DecimalFormatSymbols become the main set of rules to use.
| |
| setDecimalFormatSymbols | back to summary |
|---|---|
| public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) | |
| setNonNumericalRule | back to summary |
|---|---|
| pack-priv void setNonNumericalRule(NFRule rule) Set one of the non-numerical rules.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Builds a textual representation of a rule set. | |