| java.lang.Object com.ibm.icu.text.NFRule
NFRule | final class NFRule (Code) | | A class represnting a single rule in a RuleBasedNumberFormat. A rule
inserts its text into the result string and then passes control to its
substitutions, which do the same thing.
|
Method Summary | |
public void | doFormat(long number, StringBuffer toInsertInto, int pos) Formats the number, and inserts the resulting text into
toInsertInto. | public void | doFormat(double number, StringBuffer toInsertInto, int pos) Formats the number, and inserts the resulting text into
toInsertInto. | public Number | doParse(String text, ParsePosition parsePosition, boolean isFractionRule, double upperBound) Attempts to parse the string with this rule.
Parameters: text - The string being parsed Parameters: parsePosition - On entry, the value is ignored and assumed tobe 0. | public boolean | equals(Object that) Tests two rules for equality. | final public long | getBaseValue() | public double | getDivisor() | public static Object | makeRules(String description, NFRuleSet owner, NFRule predecessor, RuleBasedNumberFormat ownersOwner) Creates one or more rules based on the description passed in. | final public void | setBaseValue(long newBaseValue) Sets the rule's base value, and causes the radix and exponent
to be recalculated. | public boolean | shouldRollBack(double number) | public String | toString() Returns a textual representation of the rule. |
IMPROPER_FRACTION_RULE | final public static int IMPROPER_FRACTION_RULE(Code) | | Special base value used to identify an improper fraction (x.x) rule
|
MASTER_RULE | final public static int MASTER_RULE(Code) | | Special base value used to identify a master rule
|
NEGATIVE_NUMBER_RULE | final public static int NEGATIVE_NUMBER_RULE(Code) | | Special base value used to identify a negative-number rule
|
PROPER_FRACTION_RULE | final public static int PROPER_FRACTION_RULE(Code) | | Special base value used to identify a proper fraction (0.x) rule
|
NFRule | public NFRule(RuleBasedNumberFormat formatter)(Code) | | Nominal constructor for NFRule. Most of the work of constructing
an NFRule is actually performed by makeRules().
|
doFormat | public void doFormat(long number, StringBuffer toInsertInto, int pos)(Code) | | Formats the number, and inserts the resulting text into
toInsertInto.
Parameters: number - The number being formatted Parameters: toInsertInto - The string where the resultant text shouldbe inserted Parameters: pos - The position in toInsertInto where the resultant textshould be inserted |
doFormat | public void doFormat(double number, StringBuffer toInsertInto, int pos)(Code) | | Formats the number, and inserts the resulting text into
toInsertInto.
Parameters: number - The number being formatted Parameters: toInsertInto - The string where the resultant text shouldbe inserted Parameters: pos - The position in toInsertInto where the resultant textshould be inserted |
doParse | public Number doParse(String text, ParsePosition parsePosition, boolean isFractionRule, double upperBound)(Code) | | Attempts to parse the string with this rule.
Parameters: text - The string being parsed Parameters: parsePosition - On entry, the value is ignored and assumed tobe 0. On exit, this has been updated with the position of the firstcharacter not consumed by matching the text against this rule(if this rule doesn't match the text at all, the parse positionif left unchanged (presumably at 0) and the function returnsnew Long(0)). Parameters: isFractionRule - True if this rule is contained within afraction rule set. This is only used if the rule has nosubstitutions. If this rule matched the text, this is the rule's base valuecombined appropriately with the results of parsing the substitutions.If nothing matched, this is new Long(0) and the parse position isleft unchanged. The result will be an instance of Long if theresult is an integer and Double otherwise. The result is never null. |
equals | public boolean equals(Object that)(Code) | | Tests two rules for equality.
Parameters: that - The rule to compare this one against True if the two rules are functionally equivalent |
getBaseValue | final public long getBaseValue()(Code) | | Returns the rule's base value
The rule's base value |
getDivisor | public double getDivisor()(Code) | | Returns the rule's divisor (the value that cotrols the behavior
of its substitutions)
The rule's divisor |
makeRules | public static Object makeRules(String description, NFRuleSet owner, NFRule predecessor, RuleBasedNumberFormat ownersOwner)(Code) | | Creates one or more rules based on the description passed in.
Parameters: description - The description of the rule(s). Parameters: owner - The rule set containing the new rule(s). Parameters: predecessor - The rule that precedes the new one(s) in "owner"'srule list Parameters: ownersOwner - The RuleBasedNumberFormat that owns therule set that owns the new rule(s) An instance of NFRule, or an array of NFRules |
setBaseValue | final public void setBaseValue(long newBaseValue)(Code) | | 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.
Parameters: The - new base value for the rule. |
shouldRollBack | public boolean shouldRollBack(double number)(Code) | | 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)
Parameters: The - number being formatted True if the rule set should use the rule that precedesthis one in its list; false if it should use this rule |
toString | public String toString()(Code) | | 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.
A textual description of the rule |
|
|