QuanitityFormatter appears here instead of in com.ibm.icu.impl because it depends on PluralRules and DecimalFormat. It is package-protected as it is not meant for public use.
| Modifier and Type | Field and Description |
|---|---|
| private final SimpleFormatter[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addIfAbsent(CharSequence
the plural variant, e.g "zero", "one", "two", "few", "many", "other" variant, String the text for that plural variant with "{0}" as the quantity. For
example, in English, the template for the "one" variant may be "{0} apple" while the
template for the "other" variant may be "{0} apples" template)Adds a template if there is none yet for the plural form. |
| public String | Returns: the formatted string e.g '3 apples'the number to be formatted number, NumberFormat used to actually format the number. numberFormat, PluralRules uses the number and the numberFormat to determine what plural
variant to use for fetching the formatting template. pluralRules)Format formats a number with this object. |
| public static StringBuilder | format(String compiledPattern, CharSequence value, StringBuilder appendTo, FieldPosition pos)
Formats the pattern with the value and adjusts the FieldPosition. |
| public SimpleFormatter | Returns: the SimpleFormatter"zero", "one", "two", "few", "many", "other" variant)Gets the SimpleFormatter for a particular variant. |
| public boolean | |
| public static StandardPlural | selectPlural(double number, NumberFormat numberFormat, PluralRules rules)
Selects the standard plural form for the number/formatter/rules. |
| templates | back to summary |
|---|---|
| private final SimpleFormatter[] templates | |
| QuantityFormatter | back to summary |
|---|---|
| public QuantityFormatter() | |
| addIfAbsent | back to summary |
|---|---|
| public void addIfAbsent(CharSequence variant, String template) Adds a template if there is none yet for the plural form.
| |
| format | back to summary |
|---|---|
| public String format(double number, NumberFormat numberFormat, PluralRules pluralRules) Format formats a number with this object.
| |
| format | back to summary |
|---|---|
| public static StringBuilder format(String compiledPattern, CharSequence value, StringBuilder appendTo, FieldPosition pos) Formats the pattern with the value and adjusts the FieldPosition. | |
| getByVariant | back to summary |
|---|---|
| public SimpleFormatter getByVariant(CharSequence variant) Gets the SimpleFormatter for a particular variant.
| |
| isValid | back to summary |
|---|---|
public boolean isValid()
| |
| selectPlural | back to summary |
|---|---|
| public static StandardPlural selectPlural(double number, NumberFormat numberFormat, PluralRules rules) Selects the standard plural form for the number/formatter/rules. | |