/** * Formats the specified number according to the specified rule set. * @param number The number to format. * @param ruleSet The name of the rule set to format the number with. * This must be the name of a valid public rule set for this formatter. * @return A textual representation of the number. * @stable ICU 2.0 */ public String format(double number, String ruleSet) throws IllegalArgumentException { if (ruleSet.startsWith("%%")) { throw new IllegalArgumentException("Can't use internal rule set"); } return adjustForContext(format(number, findRuleSet(ruleSet))); }
/** * Formats the specified number according to the specified rule set. * (If the specified rule set specifies a master ["x.0"] rule, this function * ignores it. Convert the number to a double first if you ned it.) This * function preserves all the precision in the long-- it doesn't convert it * to a double. * @param number The number to format. * @param ruleSet The name of the rule set to format the number with. * This must be the name of a valid public rule set for this formatter. * @return A textual representation of the number. * @stable ICU 2.0 */ public String format(long number, String ruleSet) throws IllegalArgumentException { if (ruleSet.startsWith("%%")) { throw new IllegalArgumentException("Can't use internal rule set"); } return adjustForContext(format(number, findRuleSet(ruleSet))); }
if (ruleSetName == null) { if (publicRuleSetNames.length > 0) { defaultRuleSet = findRuleSet(publicRuleSetNames[0]); } else { defaultRuleSet = null; throw new IllegalArgumentException("cannot use private rule set: " + ruleSetName); } else { defaultRuleSet = findRuleSet(ruleSetName);
this.ruleSet = ruleSet.owner.findRuleSet(description); this.numberFormat = null;
defaultRuleSet = findRuleSet(publicRuleSetNames[0]); // might be different } else { publicRuleSetNames = publicRuleSetTemp;