Package com.ibm.icu.impl
Class PluralRulesLoader
java.lang.Object
com.ibm.icu.text.PluralRules.Factory
com.ibm.icu.impl.PluralRulesLoader
Loader for plural rules data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PluralRulesLoader
The only instance of the loader.private final Map<String,
PluralRules> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Lazily constructs the localeIdToRulesId and rulesIdToEquivalentULocale maps if necessary.forLocale
(ULocale locale, PluralRules.PluralType type) Returns the plural rules for the the locale.ULocale[]
Returns the locales for which we have plurals data.getFunctionalEquivalent
(ULocale locale, boolean[] isAvailable) Returns the functionally equivalent locale.Returns the lazily-constructed map.getOrCreateRulesForLocale
(ULocale locale, PluralRules.PluralType type) Gets the rule from the rulesId.Return the plurals resource.getRulesIdForLocale
(ULocale locale, PluralRules.PluralType type) Gets the rulesId from the locale,with locale fallback.Returns the lazily-constructed map.boolean
hasOverride
(ULocale locale) Returns whether or not there are overrides.Methods inherited from class com.ibm.icu.text.PluralRules.Factory
forLocale, getDefaultFactory
-
Field Details
-
pluralRulesCache
-
localeIdToCardinalRulesId
-
localeIdToOrdinalRulesId
-
rulesIdToEquivalentULocale
-
loader
The only instance of the loader.
-
-
Constructor Details
-
PluralRulesLoader
private PluralRulesLoader()Access through singleton.
-
-
Method Details
-
getAvailableULocales
Returns the locales for which we have plurals data. Utility for testing.- Specified by:
getAvailableULocales
in classPluralRules.Factory
-
getFunctionalEquivalent
Returns the functionally equivalent locale.- Specified by:
getFunctionalEquivalent
in classPluralRules.Factory
- Parameters:
locale
- the locale to checkisAvailable
- if not null and of length > 0, this will hold 'true' at index 0 if locale is directly defined (without fallback) as having plural rules- Returns:
- the functionally-equivalent locale
-
getLocaleIdToRulesIdMap
Returns the lazily-constructed map. -
getRulesIdToEquivalentULocaleMap
Returns the lazily-constructed map. -
checkBuildRulesIdMaps
private void checkBuildRulesIdMaps()Lazily constructs the localeIdToRulesId and rulesIdToEquivalentULocale maps if necessary. These exactly reflect the contents of the locales resource in plurals.res. -
getRulesIdForLocale
Gets the rulesId from the locale,with locale fallback. If there is no rulesId, return null. The rulesId might be the empty string if the rule is the default rule. -
getOrCreateRulesForLocale
Gets the rule from the rulesId. If there is no rule for this rulesId, return null. -
getPluralBundle
Return the plurals resource. Note MissingResourceException is unchecked, listed here for clarity. Callers should handle this exception.- Throws:
MissingResourceException
-
forLocale
Returns the plural rules for the the locale. If we don't have data, com.ibm.icu.text.PluralRules.DEFAULT is returned.- Specified by:
forLocale
in classPluralRules.Factory
- Parameters:
locale
- The locale for which aPluralRules
object is returned.type
- The plural type (e.g., cardinal or ordinal).- Returns:
- The predefined
PluralRules
object for this locale. If there's no predefined rules for this locale, the rules for the closest parent in the locale hierarchy that has one will be returned. The final fallback always returns the default rules.
-
hasOverride
Description copied from class:PluralRules.Factory
Returns whether or not there are overrides.- Specified by:
hasOverride
in classPluralRules.Factory
-