Class PluralRules
Helps to determine the plural category for a given number of units.
The predefined rules for any given language are based on CLDR-version 26 but can be overridden if necessary. The source data of the underlying algorithms to determine the plural category can be found in CLDR-repository-file "core.zip" along the path "common/supplemental/plurals.xml" for cardinal numbers and "common/supplemental/ordinals.xml" for ordinal numbers.
Note: All concrete subclasses must be immutable.
- Since:
- 1.2
- Author:
- Meno Hochschild
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract PluralCategory
getCategory(long count)
Determines the plural category for given number of units.abstract NumberType
Yields the number type these rules are referring to.static PluralRules
of(Locale locale, NumberType numType)
Gets the localized plural rules for given language or country.static void
register(Locale locale, PluralRules rules)
Registers given plural rules for a language, possibly overriding CLDR-default setting.
-
Constructor Details
-
PluralRules
public PluralRules()
-
-
Method Details
-
of
Gets the localized plural rules for given language or country.
If no rules can be found then Time4J will choose the default rules for cardinals which apply
PluralCategory.ONE
to n=1 and else apply the fallback categoryPluralCategory.OTHER
.- Parameters:
locale
- locale which specifies the suitable plural rulesnumType
- number type- Returns:
- localized plural rules
- Since:
- 1.2
-
register
Registers given plural rules for a language, possibly overriding CLDR-default setting.
- Parameters:
locale
- language or country which the rules shall be assigned torules
- localized plural rules- Since:
- 1.2
-
getCategory
Determines the plural category for given number of units.
- Parameters:
count
- integral number of units- Returns:
- plural category, never
null
- Since:
- 1.2
-
getNumberType
Yields the number type these rules are referring to.
- Returns:
- number type
- Since:
- 1.2
-