Top Description Fields Constructors Methods
com.ibm.icu.impl

public Class PluralRulesLoader

extends Factory
Class Inheritance
Imports
java.text.ParseException, java.util.Collections, .HashMap, .Iterator, .LinkedHashSet, .Map, .MissingResourceException, .Set, .TreeMap, com.ibm.icu.impl.number.range.StandardPluralRanges, com.ibm.icu.text.PluralRules, .PluralRules.PluralType, com.ibm.icu.util.ULocale, .UResourceBundle

Deprecated

as a consequence of PluralRules.Factory being deprecated. See corresponding docs for further information.

Loader for plural rules data.

Field Summary

Modifier and TypeField and Description
public static final PluralRulesLoader
loader

The only instance of the loader.

private Map<String, String>
private Map<String, String>
private final Map<String, PluralRules>
private Map<String, ULocale>

Constructor Summary

AccessConstructor and Description
private
PluralRulesLoader()

Access through singleton.

Method Summary

Modifier and TypeMethod and Description
private void
checkBuildRulesIdMaps()

Lazily constructs the localeIdToRulesId and rulesIdToEquivalentULocale maps if necessary.

public PluralRules
forLocale(ULocale
The locale for which a PluralRules object is returned.
locale
,
PluralRules.PluralType
The plural type (e.g., cardinal or ordinal).
type
)

Implements abstract com.ibm.icu.text.PluralRules.Factory.forLocale.

Returns the plural rules for the the locale.
public ULocale[]
getAvailableULocales()

Implements abstract com.ibm.icu.text.PluralRules.Factory.getAvailableULocales.

Returns the locales for which we have plurals data.
public ULocale
getFunctionalEquivalent(ULocale
the locale to check
locale
,
boolean[]
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
isAvailable
)

Implements abstract com.ibm.icu.text.PluralRules.Factory.getFunctionalEquivalent.

Returns the functionally equivalent locale.
private Map<String, String>
getLocaleIdToRulesIdMap(PluralRules.PluralType type)

Returns the lazily-constructed map.

public PluralRules
getOrCreateRulesForLocale(ULocale locale, PluralRules.PluralType type)

Gets the rule from the rulesId.

public UResourceBundle
getPluralBundle()

Return the plurals resource.

public String
getRulesIdForLocale(ULocale locale, PluralRules.PluralType type)

Gets the rulesId from the locale,with locale fallback.

private Map<String, ULocale>
getRulesIdToEquivalentULocaleMap()

Returns the lazily-constructed map.

public boolean
hasOverride(ULocale locale)

Implements abstract com.ibm.icu.text.PluralRules.Factory.hasOverride.

Returns whether or not there are overrides.
Inherited from com.ibm.icu.text.PluralRules.Factory:
forLocalegetDefaultFactory

Field Detail

loaderback to summary
public static final PluralRulesLoader loader

Deprecated

as a consequence of PluralRulesLoader being deprecated. See corresponding docs for further information.

The only instance of the loader.

localeIdToCardinalRulesIdback to summary
private Map<String, String> localeIdToCardinalRulesId
localeIdToOrdinalRulesIdback to summary
private Map<String, String> localeIdToOrdinalRulesId
pluralRulesCacheback to summary
private final Map<String, PluralRules> pluralRulesCache
rulesIdToEquivalentULocaleback to summary
private Map<String, ULocale> rulesIdToEquivalentULocale

Constructor Detail

PluralRulesLoaderback to summary
private PluralRulesLoader()

Access through singleton.

Method Detail

checkBuildRulesIdMapsback to summary
private void checkBuildRulesIdMaps()

Lazily constructs the localeIdToRulesId and rulesIdToEquivalentULocale maps if necessary. These exactly reflect the contents of the locales resource in plurals.res.

forLocaleback to summary
public PluralRules forLocale(ULocale locale, PluralRules.PluralType type)

Implements abstract com.ibm.icu.text.PluralRules.Factory.forLocale.

Returns the plural rules for the the locale. If we don't have data, com.ibm.icu.text.PluralRules.DEFAULT is returned.

Parameters
locale:ULocale

Doc from com.ibm.icu.text.PluralRules.Factory.forLocale.

The locale for which a PluralRules object is returned.

type:PluralRules.PluralType

Doc from com.ibm.icu.text.PluralRules.Factory.forLocale.

The plural type (e.g., cardinal or ordinal).

Returns:PluralRules

Doc from com.ibm.icu.text.PluralRules.Factory.forLocale.

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.

getAvailableULocalesback to summary
public ULocale[] getAvailableULocales()

Implements abstract com.ibm.icu.text.PluralRules.Factory.getAvailableULocales.

Returns the locales for which we have plurals data. Utility for testing.

getFunctionalEquivalentback to summary
public ULocale getFunctionalEquivalent(ULocale locale, boolean[] isAvailable)

Implements abstract com.ibm.icu.text.PluralRules.Factory.getFunctionalEquivalent.

Returns the functionally equivalent locale.

Parameters
locale:ULocale

Doc from com.ibm.icu.text.PluralRules.Factory.getFunctionalEquivalent.

the locale to check

isAvailable:boolean[]

Doc from com.ibm.icu.text.PluralRules.Factory.getFunctionalEquivalent.

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:ULocale

Doc from com.ibm.icu.text.PluralRules.Factory.getFunctionalEquivalent.

the functionally-equivalent locale

getLocaleIdToRulesIdMapback to summary
private Map<String, String> getLocaleIdToRulesIdMap(PluralRules.PluralType type)

Returns the lazily-constructed map.

getOrCreateRulesForLocaleback to summary
public PluralRules getOrCreateRulesForLocale(ULocale locale, PluralRules.PluralType type)

Gets the rule from the rulesId. If there is no rule for this rulesId, return null.

getPluralBundleback to summary
public UResourceBundle getPluralBundle() throws MissingResourceException

Return the plurals resource. Note MissingResourceException is unchecked, listed here for clarity. Callers should handle this exception.

getRulesIdForLocaleback to summary
public String getRulesIdForLocale(ULocale locale, PluralRules.PluralType type)

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.

getRulesIdToEquivalentULocaleMapback to summary
private Map<String, ULocale> getRulesIdToEquivalentULocaleMap()

Returns the lazily-constructed map.

hasOverrideback to summary
public boolean hasOverride(ULocale locale)

Implements abstract com.ibm.icu.text.PluralRules.Factory.hasOverride.

Doc from com.ibm.icu.text.PluralRules.Factory.hasOverride.

Returns whether or not there are overrides.

Annotations
@Override