Package com.ibm.icu.impl
Class ICUResourceBundle
- java.lang.Object
-
- java.util.ResourceBundle
-
- com.ibm.icu.util.UResourceBundle
-
- com.ibm.icu.impl.ICUResourceBundle
-
- Direct Known Subclasses:
ICUResourceBundleImpl
public class ICUResourceBundle extends UResourceBundle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ICUResourceBundle.AvailableLocalesSink
private static class
ICUResourceBundle.AvailEntry
Holds the prefix, and lazily creates the Locale[] list or the locale name Set as needed.private static class
ICUResourceBundle.Loader
Loader for bundle instances, for caching.static class
ICUResourceBundle.OpenType
protected static class
ICUResourceBundle.WholeBundle
Fields for a whole bundle, rather than any specific resource in the bundle.
-
Field Summary
Fields Modifier and Type Field Description static int
ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource storing the data (can be in a different resource bundle).static int
ARRAY16
Resource type constant for arrays with 16-bit count and values.private static CacheBase<java.lang.String,ICUResourceBundle,ICUResourceBundle.Loader>
BUNDLE_CACHE
private static java.util.Comparator<java.lang.String[]>
COMPARE_FIRST_ELEMENT
private ICUResourceBundle
container
private static boolean
DEBUG
private static java.lang.String
DEFAULT_TAG
private static java.lang.String
FULL_LOCALE_NAMES_LIST
private static CacheBase<java.lang.String,ICUResourceBundle.AvailEntry,java.lang.ClassLoader>
GET_AVAILABLE_CACHE
private static char
HYPHEN
static java.lang.ClassLoader
ICU_DATA_CLASS_LOADER
The class loader constant to be used with getBundleInstance APIprivate static java.lang.String
ICU_RESOURCE_INDEX
private static java.lang.String
ICUDATA
protected static java.lang.String
INSTALLED_LOCALES
The name of the resource containing the installed localesprotected java.lang.String
key
Data member where the subclasses store the key.private static java.lang.String
LOCALE
static java.lang.String
NO_INHERITANCE_MARKER
CLDR string value "∅∅∅" prevents fallback to the parent bundle.static int
RES_BOGUS
A resource word value that means "no resource".private static char
RES_PATH_SEP_CHAR
private static java.lang.String
RES_PATH_SEP_STR
static int
STRING_V2
Resource type constant for 16-bit Unicode strings in formatVersion 2.static int
TABLE16
Resource type constant for tables with 16-bit count, key offsets and values.static int
TABLE32
Resource type constant for tables with 32-bit count, key offsets and values.(package private) ICUResourceBundle.WholeBundle
wholeBundle
-
Fields inherited from class com.ibm.icu.util.UResourceBundle
ARRAY, BINARY, INT, INT_VECTOR, NONE, STRING, TABLE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ICUResourceBundle(ICUResourceBundle.WholeBundle wholeBundle)
Constructor for the root table of a bundle.protected
ICUResourceBundle(ICUResourceBundle container, java.lang.String key)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static void
addBundleBaseNamesFromClassLoader(java.lang.String bn, java.lang.ClassLoader root, java.util.Set<java.lang.String> names)
private static void
addLocaleIDsFromIndexBundle(java.lang.String baseName, java.lang.ClassLoader root, java.util.Set<java.lang.String> locales)
private static void
addLocaleIDsFromListFile(java.lang.String bn, java.lang.ClassLoader root, java.util.Set<java.lang.String> locales)
ICUResourceBundle
at(int index)
ICUResourceBundle
at(java.lang.String key)
private static int
countPathKeys(java.lang.String path)
static ICUResourceBundle
createBundle(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root)
Create a bundle using a reader.private static java.util.Set<java.lang.String>
createFullLocaleNameSet(java.lang.String baseName, java.lang.ClassLoader loader)
private static java.util.Set<java.lang.String>
createLocaleNameSet(java.lang.String baseName, java.lang.ClassLoader loader)
private static java.util.EnumMap<ULocale.AvailableType,ULocale[]>
createULocaleList(java.lang.String baseName, java.lang.ClassLoader root)
boolean
equals(java.lang.Object other)
private static ICUResourceBundle
findResourceWithFallback(java.lang.String[] keys, int depth, ICUResourceBundle base, UResourceBundle requested)
private static ICUResourceBundle
findResourceWithFallback(java.lang.String path, UResourceBundle actualBundle, UResourceBundle requested)
java.lang.String
findStringWithFallback(java.lang.String path)
private static java.lang.String
findStringWithFallback(java.lang.String path, UResourceBundle actualBundle, UResourceBundle requested)
Like findResourceWithFallback(...).getString() but with minimal creation of intermediate ICUResourceBundle objects.ICUResourceBundle
findTopLevel(int index)
Returns a resource in a given resource that has a given index, or null if the resource is not found.ICUResourceBundle
findTopLevel(java.lang.String aKey)
Returns a resource in a given resource that has a given key, or null if the resource is not found.ICUResourceBundle
findWithFallback(java.lang.String path)
Like getWithFallback, but returns null if the resource is not found instead of throwing an exception.(package private) ICUResourceBundle
get(java.lang.String aKey, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
protected static ICUResourceBundle
getAliasedResource(ICUResourceBundle base, java.lang.String[] keys, int depth, java.lang.String key, int _resource, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
Returns the resource object referred to from the alias _resource int's path string.protected static ICUResourceBundle
getAliasedResource(java.lang.String rpath, java.lang.ClassLoader loaderToUse, java.lang.String baseName, java.lang.String[] keys, int depth, java.lang.String[] baseKeyPath, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
void
getAllChildrenWithFallback(java.lang.String path, UResource.Sink sink)
Locates the resource specified bypath
in this resource bundle (performing any necessary fallback and following any aliases) and, if the resource is a table resource, iterates over its immediate child resources (again, following any aliases to get the individual resource values), and calls the specifiedsink
'sput()
method for each child resource (passing it that resource's key and either its actual value or, if that value is an alias, the value you get by following the alias).private void
getAllItemsWithFallback(UResource.Key key, ICUResourceBundleReader.ReaderValue readerValue, UResource.Sink sink, UResourceBundle requested)
void
getAllItemsWithFallback(java.lang.String path, UResource.Sink sink)
Locates the resource specified bypath
in this resource bundle (performing any necessary fallback and following any aliases) and calls the specifiedsink
'sput()
method with that resource.void
getAllItemsWithFallbackNoFail(java.lang.String path, UResource.Sink sink)
static java.util.Set<java.lang.String>
getAvailableLocaleNameSet()
Return a set of the locale names supported by a collection of resource bundles.static java.util.Set<java.lang.String>
getAvailableLocaleNameSet(java.lang.String bundlePrefix, java.lang.ClassLoader loader)
Return a set of the locale names supported by a collection of resource bundles.static java.util.Locale[]
getAvailableLocales()
Get the set of ULocales installed the base bundle.static java.util.Locale[]
getAvailableLocales(ULocale.AvailableType type)
Get the set of Locales installed the base bundle, for the specified type.static java.util.Locale[]
getAvailableLocales(java.lang.String baseName, java.lang.ClassLoader loader)
Get the set of Locales installed in the specified bundles.static java.util.Locale[]
getAvailableLocales(java.lang.String baseName, java.lang.ClassLoader loader, ULocale.AvailableType type)
Get the set of Locales installed in the specified bundles, for the specified type.static ULocale[]
getAvailableULocales()
Get the set of ULocales installed the base bundle.static ULocale[]
getAvailableULocales(ULocale.AvailableType type)
Get the set of ULocales installed the base bundle, for the specified type.static ULocale[]
getAvailableULocales(java.lang.String baseName, java.lang.ClassLoader loader)
Get the set of Locales installed in the specified bundles.static ULocale[]
getAvailableULocales(java.lang.String baseName, java.lang.ClassLoader loader, ULocale.AvailableType type)
Get the set of Locales installed in the specified bundles, for the specified type.private static ICUResourceBundle.AvailEntry
getAvailEntry(java.lang.String key, java.lang.ClassLoader loader)
Stores the locale information in a cache accessed by key (bundle prefix).protected java.lang.String
getBaseName()
Returns the base name of the resource bundleprivate static ICUResourceBundle
getBundle(ICUResourceBundleReader reader, java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader loader)
static ICUResourceBundle
getBundleInstance(java.lang.String baseName, ULocale locale, ICUResourceBundle.OpenType openType)
static ICUResourceBundle
getBundleInstance(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root, boolean disableFallback)
static ICUResourceBundle
getBundleInstance(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root, ICUResourceBundle.OpenType openType)
private static java.lang.String
getDefaultScript(java.lang.String language, java.lang.String region)
private static java.lang.String
getExplicitParent(java.lang.String localeID)
static java.util.Set<java.lang.String>
getFullLocaleNameSet()
Return a set of all the locale names supported by a collection of resource bundles.static java.util.Set<java.lang.String>
getFullLocaleNameSet(java.lang.String bundlePrefix, java.lang.ClassLoader loader)
Return a set of all the locale names supported by a collection of resource bundles.static ULocale
getFunctionalEquivalent(java.lang.String baseName, java.lang.ClassLoader loader, java.lang.String resName, java.lang.String keyword, ULocale locID, boolean[] isAvailable, boolean omitDefault)
Returns a functionally equivalent locale, considering keywords as well, for the specified keyword.java.lang.String
getKey()
Returns the key associated with a given resource.static java.lang.String[]
getKeywordValues(java.lang.String baseName, java.lang.String keyword)
Given a tree path and keyword, return a string enumeration of all possible values for that keyword.java.util.Locale
getLocale()
Returns the locale of this resource bundle.protected java.lang.String
getLocaleID()
Returns the localeIDstatic java.util.Locale[]
getLocaleList(ULocale[] ulocales)
Convert a list of ULocales to a list of Locales.private boolean
getNoFallback()
Get the noFallback flag specified in the loaded bundle.ICUResourceBundle
getParent()
Returns the parent bundlestatic java.lang.String
getParentLocaleID(java.lang.String name, java.lang.String origName, ICUResourceBundle.OpenType openType)
private int
getResDepth()
private void
getResPathKeys(java.lang.String[] keys, int depth)
Fills some of the keys array with the keys on the path to this resource object.private static void
getResPathKeys(java.lang.String path, int num, java.lang.String[] keys, int start)
Fills some of the keys array (from start) with the num keys from the path string.java.lang.String
getStringWithFallback(java.lang.String path)
java.util.Set<java.lang.String>
getTopLevelKeySet()
Deprecated.This API is ICU internal only.ULocale
getULocale()
Returns the RFC 3066 conformant locale id of this resource bundle.UResource.Value
getValueWithFallback(java.lang.String path)
ICUResourceBundle
getWithFallback(java.lang.String path)
This method performs multilevel fallback for fetching items from the bundle e.g: If resource is in the form de__PHONEBOOK{ collations{ default{ "phonebook"} } } If the value of "default" key needs to be accessed, then do:UResourceBundle bundle = UResourceBundle.getBundleInstance("de__PHONEBOOK"); ICUResourceBundle result = null; if(bundle instanceof ICUResourceBundle){ result = ((ICUResourceBundle) bundle).getWithFallback("collations/default"); }
protected java.util.Enumeration<java.lang.String>
handleGetKeys()
Actual worker method for fetching the keys of resources contained in the resource.int
hashCode()
private static ICUResourceBundle
instantiateBundle(java.lang.String baseName, java.lang.String localeID, java.lang.String origLocaleID, java.lang.String defaultID, java.lang.ClassLoader root, ICUResourceBundle.OpenType openType)
boolean
isRoot()
Returns true if this is the root bundle, or an item in the root bundle.protected boolean
isTopLevelResource()
Is this a top-level resource, that is, a whole bundle?private static boolean
localeIDStartsWithLangSubtag(java.lang.String localeID, java.lang.String lang)
protected void
setParent(java.util.ResourceBundle parent)
void
setTopLevelKeySet(java.util.Set<java.lang.String> keySet)
Deprecated.This API is ICU internal only.-
Methods inherited from class com.ibm.icu.util.UResourceBundle
get, get, getBinary, getBinary, getBundleInstance, getBundleInstance, getBundleInstance, getBundleInstance, getBundleInstance, getBundleInstance, getBundleInstance, getBundleInstance, getInt, getIntVector, getIterator, getKeys, getSize, getString, getString, getStringArray, getType, getUInt, getVersion, handleGet, handleGet, handleGetObject, handleGetStringArray, handleKeySet, instantiateBundle, keySet
-
-
-
-
Field Detail
-
NO_INHERITANCE_MARKER
public static final java.lang.String NO_INHERITANCE_MARKER
CLDR string value "∅∅∅" prevents fallback to the parent bundle.- See Also:
- Constant Field Values
-
ICU_DATA_CLASS_LOADER
public static final java.lang.ClassLoader ICU_DATA_CLASS_LOADER
The class loader constant to be used with getBundleInstance API
-
INSTALLED_LOCALES
protected static final java.lang.String INSTALLED_LOCALES
The name of the resource containing the installed locales- See Also:
- Constant Field Values
-
wholeBundle
ICUResourceBundle.WholeBundle wholeBundle
-
container
private ICUResourceBundle container
-
BUNDLE_CACHE
private static CacheBase<java.lang.String,ICUResourceBundle,ICUResourceBundle.Loader> BUNDLE_CACHE
-
ICU_RESOURCE_INDEX
private static final java.lang.String ICU_RESOURCE_INDEX
- See Also:
- Constant Field Values
-
DEFAULT_TAG
private static final java.lang.String DEFAULT_TAG
- See Also:
- Constant Field Values
-
FULL_LOCALE_NAMES_LIST
private static final java.lang.String FULL_LOCALE_NAMES_LIST
- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
-
GET_AVAILABLE_CACHE
private static CacheBase<java.lang.String,ICUResourceBundle.AvailEntry,java.lang.ClassLoader> GET_AVAILABLE_CACHE
-
COMPARE_FIRST_ELEMENT
private static final java.util.Comparator<java.lang.String[]> COMPARE_FIRST_ELEMENT
-
key
protected java.lang.String key
Data member where the subclasses store the key.
-
RES_BOGUS
public static final int RES_BOGUS
A resource word value that means "no resource". Note: 0xffffffff == -1 This has the same value as UResourceBundle.NONE, but they are semantically different and should be used appropriately according to context: NONE means "no type". (The type of RES_BOGUS is RES_RESERVED=15 which was defined in ICU4C ures.h.)- See Also:
- Constant Field Values
-
ALIAS
public static final int ALIAS
Resource type constant for aliases; internally stores a string which identifies the actual resource storing the data (can be in a different resource bundle). Resolved internally before delivering the actual resource through the API.- See Also:
- Constant Field Values
-
TABLE32
public static final int TABLE32
Resource type constant for tables with 32-bit count, key offsets and values.- See Also:
- Constant Field Values
-
TABLE16
public static final int TABLE16
Resource type constant for tables with 16-bit count, key offsets and values. All values are STRING_V2 strings.- See Also:
- Constant Field Values
-
STRING_V2
public static final int STRING_V2
Resource type constant for 16-bit Unicode strings in formatVersion 2.- See Also:
- Constant Field Values
-
ARRAY16
public static final int ARRAY16
Resource type constant for arrays with 16-bit count and values. All values are STRING_V2 strings.- See Also:
- Constant Field Values
-
RES_PATH_SEP_CHAR
private static final char RES_PATH_SEP_CHAR
- See Also:
- Constant Field Values
-
RES_PATH_SEP_STR
private static final java.lang.String RES_PATH_SEP_STR
- See Also:
- Constant Field Values
-
ICUDATA
private static final java.lang.String ICUDATA
- See Also:
- Constant Field Values
-
HYPHEN
private static final char HYPHEN
- See Also:
- Constant Field Values
-
LOCALE
private static final java.lang.String LOCALE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ICUResourceBundle
protected ICUResourceBundle(ICUResourceBundle.WholeBundle wholeBundle)
Constructor for the root table of a bundle.
-
ICUResourceBundle
protected ICUResourceBundle(ICUResourceBundle container, java.lang.String key)
-
-
Method Detail
-
getFunctionalEquivalent
public static final ULocale getFunctionalEquivalent(java.lang.String baseName, java.lang.ClassLoader loader, java.lang.String resName, java.lang.String keyword, ULocale locID, boolean[] isAvailable, boolean omitDefault)
Returns a functionally equivalent locale, considering keywords as well, for the specified keyword.- Parameters:
baseName
- resource specifierresName
- top level resource to consider (such as "collations")keyword
- a particular keyword to consider (such as "collation" )locID
- The requested localeisAvailable
- If non-null, 1-element array of fillin parameter that indicates whether the requested locale was available. The locale is defined as 'available' if it physically exists within the specified tree and included in 'InstalledLocales'.omitDefault
- if true, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'- Returns:
- the locale
-
getKeywordValues
public static final java.lang.String[] getKeywordValues(java.lang.String baseName, java.lang.String keyword)
Given a tree path and keyword, return a string enumeration of all possible values for that keyword.- Parameters:
baseName
- resource specifierkeyword
- a particular keyword to consider, must match a top level resource name within the tree. (i.e. "collations")
-
getWithFallback
public ICUResourceBundle getWithFallback(java.lang.String path) throws java.util.MissingResourceException
This method performs multilevel fallback for fetching items from the bundle e.g: If resource is in the form de__PHONEBOOK{ collations{ default{ "phonebook"} } } If the value of "default" key needs to be accessed, then do:UResourceBundle bundle = UResourceBundle.getBundleInstance("de__PHONEBOOK"); ICUResourceBundle result = null; if(bundle instanceof ICUResourceBundle){ result = ((ICUResourceBundle) bundle).getWithFallback("collations/default"); }
- Parameters:
path
- The path to the required resource key- Returns:
- resource represented by the key
- Throws:
java.util.MissingResourceException
- If a resource was not found.
-
at
public ICUResourceBundle at(int index)
-
at
public ICUResourceBundle at(java.lang.String key)
-
findTopLevel
public ICUResourceBundle findTopLevel(int index)
Description copied from class:UResourceBundle
Returns a resource in a given resource that has a given index, or null if the resource is not found.- Overrides:
findTopLevel
in classUResourceBundle
- Parameters:
index
- the index of the resource- Returns:
- the resource, or null
- See Also:
UResourceBundle.get(int)
-
findTopLevel
public ICUResourceBundle findTopLevel(java.lang.String aKey)
Description copied from class:UResourceBundle
Returns a resource in a given resource that has a given key, or null if the resource is not found.- Overrides:
findTopLevel
in classUResourceBundle
- Parameters:
aKey
- the key associated with the wanted resource- Returns:
- the resource, or null
- See Also:
UResourceBundle.get(String)
-
findWithFallback
public ICUResourceBundle findWithFallback(java.lang.String path)
Like getWithFallback, but returns null if the resource is not found instead of throwing an exception.- Parameters:
path
- the path to the resource- Returns:
- the resource, or null
-
findStringWithFallback
public java.lang.String findStringWithFallback(java.lang.String path)
-
getStringWithFallback
public java.lang.String getStringWithFallback(java.lang.String path) throws java.util.MissingResourceException
- Throws:
java.util.MissingResourceException
-
getValueWithFallback
public UResource.Value getValueWithFallback(java.lang.String path) throws java.util.MissingResourceException
- Throws:
java.util.MissingResourceException
-
getAllItemsWithFallbackNoFail
public void getAllItemsWithFallbackNoFail(java.lang.String path, UResource.Sink sink)
-
getAllItemsWithFallback
public void getAllItemsWithFallback(java.lang.String path, UResource.Sink sink) throws java.util.MissingResourceException
Locates the resource specified bypath
in this resource bundle (performing any necessary fallback and following any aliases) and calls the specifiedsink
'sput()
method with that resource. Then walks the bundle's parent chain, callingput()
on the sink for each item in the parent chain.- Parameters:
path
- The path of the desired resourcesink
- AUResource.Sink
that gets called for each resource in the parent chain- Throws:
java.util.MissingResourceException
-
getAllChildrenWithFallback
public void getAllChildrenWithFallback(java.lang.String path, UResource.Sink sink) throws java.util.MissingResourceException
Locates the resource specified bypath
in this resource bundle (performing any necessary fallback and following any aliases) and, if the resource is a table resource, iterates over its immediate child resources (again, following any aliases to get the individual resource values), and calls the specifiedsink
'sput()
method for each child resource (passing it that resource's key and either its actual value or, if that value is an alias, the value you get by following the alias). Then walks back over the bundle's parent chain, similarly iterating over each parent table resource's child resources. Does not descend beyond one level of table children.- Parameters:
path
- The path of the desired resourcesink
- AUResource.Sink
that gets called for each child resource of the specified resource (and each child of the resources in its parent chain).- Throws:
java.util.MissingResourceException
-
getAllItemsWithFallback
private void getAllItemsWithFallback(UResource.Key key, ICUResourceBundleReader.ReaderValue readerValue, UResource.Sink sink, UResourceBundle requested)
-
getAvailableLocaleNameSet
public static java.util.Set<java.lang.String> getAvailableLocaleNameSet(java.lang.String bundlePrefix, java.lang.ClassLoader loader)
Return a set of the locale names supported by a collection of resource bundles.- Parameters:
bundlePrefix
- the prefix of the resource bundles to use.
-
getFullLocaleNameSet
public static java.util.Set<java.lang.String> getFullLocaleNameSet()
Return a set of all the locale names supported by a collection of resource bundles.
-
getFullLocaleNameSet
public static java.util.Set<java.lang.String> getFullLocaleNameSet(java.lang.String bundlePrefix, java.lang.ClassLoader loader)
Return a set of all the locale names supported by a collection of resource bundles.- Parameters:
bundlePrefix
- the prefix of the resource bundles to use.
-
getAvailableLocaleNameSet
public static java.util.Set<java.lang.String> getAvailableLocaleNameSet()
Return a set of the locale names supported by a collection of resource bundles.
-
getAvailableULocales
public static final ULocale[] getAvailableULocales(java.lang.String baseName, java.lang.ClassLoader loader, ULocale.AvailableType type)
Get the set of Locales installed in the specified bundles, for the specified type.- Returns:
- the list of available locales
-
getAvailableULocales
public static final ULocale[] getAvailableULocales()
Get the set of ULocales installed the base bundle.- Returns:
- the list of available locales
-
getAvailableULocales
public static final ULocale[] getAvailableULocales(ULocale.AvailableType type)
Get the set of ULocales installed the base bundle, for the specified type.- Returns:
- the list of available locales for the specified type
-
getAvailableULocales
public static final ULocale[] getAvailableULocales(java.lang.String baseName, java.lang.ClassLoader loader)
Get the set of Locales installed in the specified bundles.- Returns:
- the list of available locales
-
getAvailableLocales
public static final java.util.Locale[] getAvailableLocales(java.lang.String baseName, java.lang.ClassLoader loader, ULocale.AvailableType type)
Get the set of Locales installed in the specified bundles, for the specified type.- Returns:
- the list of available locales
-
getAvailableLocales
public static final java.util.Locale[] getAvailableLocales()
Get the set of ULocales installed the base bundle.- Returns:
- the list of available locales
-
getAvailableLocales
public static final java.util.Locale[] getAvailableLocales(ULocale.AvailableType type)
Get the set of Locales installed the base bundle, for the specified type.- Returns:
- the list of available locales
-
getAvailableLocales
public static final java.util.Locale[] getAvailableLocales(java.lang.String baseName, java.lang.ClassLoader loader)
Get the set of Locales installed in the specified bundles.- Returns:
- the list of available locales
-
getLocaleList
public static final java.util.Locale[] getLocaleList(ULocale[] ulocales)
Convert a list of ULocales to a list of Locales. ULocales with a script code will not be converted since they cannot be represented as a Locale. This means that the two lists will not match one-to-one, and that the returned list might be shorter than the input list.- Parameters:
ulocales
- a list of ULocales to convert to a list of Locales.- Returns:
- the list of converted ULocales
-
getLocale
public java.util.Locale getLocale()
Returns the locale of this resource bundle. This method can be used after a call to getBundle() to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback.- Overrides:
getLocale
in classUResourceBundle
- Returns:
- the locale of this resource bundle
-
createULocaleList
private static final java.util.EnumMap<ULocale.AvailableType,ULocale[]> createULocaleList(java.lang.String baseName, java.lang.ClassLoader root)
-
addLocaleIDsFromIndexBundle
private static final void addLocaleIDsFromIndexBundle(java.lang.String baseName, java.lang.ClassLoader root, java.util.Set<java.lang.String> locales)
-
addBundleBaseNamesFromClassLoader
private static final void addBundleBaseNamesFromClassLoader(java.lang.String bn, java.lang.ClassLoader root, java.util.Set<java.lang.String> names)
-
addLocaleIDsFromListFile
private static void addLocaleIDsFromListFile(java.lang.String bn, java.lang.ClassLoader root, java.util.Set<java.lang.String> locales)
-
createFullLocaleNameSet
private static java.util.Set<java.lang.String> createFullLocaleNameSet(java.lang.String baseName, java.lang.ClassLoader loader)
-
createLocaleNameSet
private static java.util.Set<java.lang.String> createLocaleNameSet(java.lang.String baseName, java.lang.ClassLoader loader)
-
getAvailEntry
private static ICUResourceBundle.AvailEntry getAvailEntry(java.lang.String key, java.lang.ClassLoader loader)
Stores the locale information in a cache accessed by key (bundle prefix). The cached objects are AvailEntries. The cache is implemented by SoftCache so it can be GC'd.
-
findResourceWithFallback
private static final ICUResourceBundle findResourceWithFallback(java.lang.String path, UResourceBundle actualBundle, UResourceBundle requested)
-
findResourceWithFallback
private static final ICUResourceBundle findResourceWithFallback(java.lang.String[] keys, int depth, ICUResourceBundle base, UResourceBundle requested)
-
findStringWithFallback
private static final java.lang.String findStringWithFallback(java.lang.String path, UResourceBundle actualBundle, UResourceBundle requested)
Like findResourceWithFallback(...).getString() but with minimal creation of intermediate ICUResourceBundle objects.
-
getResDepth
private int getResDepth()
-
getResPathKeys
private void getResPathKeys(java.lang.String[] keys, int depth)
Fills some of the keys array with the keys on the path to this resource object. Writes the top-level key into index 0 and increments from there.- Parameters:
keys
-depth
- must begetResDepth()
-
countPathKeys
private static int countPathKeys(java.lang.String path)
-
getResPathKeys
private static void getResPathKeys(java.lang.String path, int num, java.lang.String[] keys, int start)
Fills some of the keys array (from start) with the num keys from the path string.- Parameters:
path
- path stringnum
- must becountPathKeys(String)
keys
-start
- index where the first path key is stored
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getBundleInstance
public static ICUResourceBundle getBundleInstance(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root, boolean disableFallback)
-
getBundleInstance
public static ICUResourceBundle getBundleInstance(java.lang.String baseName, ULocale locale, ICUResourceBundle.OpenType openType)
-
getBundleInstance
public static ICUResourceBundle getBundleInstance(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root, ICUResourceBundle.OpenType openType)
-
localeIDStartsWithLangSubtag
private static boolean localeIDStartsWithLangSubtag(java.lang.String localeID, java.lang.String lang)
-
getExplicitParent
private static java.lang.String getExplicitParent(java.lang.String localeID)
-
getDefaultScript
private static java.lang.String getDefaultScript(java.lang.String language, java.lang.String region)
-
getParentLocaleID
public static java.lang.String getParentLocaleID(java.lang.String name, java.lang.String origName, ICUResourceBundle.OpenType openType)
-
instantiateBundle
private static ICUResourceBundle instantiateBundle(java.lang.String baseName, java.lang.String localeID, java.lang.String origLocaleID, java.lang.String defaultID, java.lang.ClassLoader root, ICUResourceBundle.OpenType openType)
-
get
ICUResourceBundle get(java.lang.String aKey, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
-
createBundle
public static ICUResourceBundle createBundle(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root)
Create a bundle using a reader.- Parameters:
baseName
- The name for the bundle.localeID
- The locale identification.root
- The ClassLoader object root.- Returns:
- the new bundle
-
getLocaleID
protected java.lang.String getLocaleID()
Description copied from class:UResourceBundle
Returns the localeID- Specified by:
getLocaleID
in classUResourceBundle
- Returns:
- The string representation of the localeID
-
getBaseName
protected java.lang.String getBaseName()
Description copied from class:UResourceBundle
Returns the base name of the resource bundle- Specified by:
getBaseName
in classUResourceBundle
- Returns:
- The string representation of the base name
-
getULocale
public ULocale getULocale()
Description copied from class:UResourceBundle
Returns the RFC 3066 conformant locale id of this resource bundle. This method can be used after a call to getBundleInstance() to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback.- Specified by:
getULocale
in classUResourceBundle
- Returns:
- the locale of this resource bundle
-
isRoot
public boolean isRoot()
Returns true if this is the root bundle, or an item in the root bundle.
-
getParent
public ICUResourceBundle getParent()
Description copied from class:UResourceBundle
Returns the parent bundle- Specified by:
getParent
in classUResourceBundle
- Returns:
- The parent bundle
-
setParent
protected void setParent(java.util.ResourceBundle parent)
- Overrides:
setParent
in classjava.util.ResourceBundle
-
getKey
public java.lang.String getKey()
Description copied from class:UResourceBundle
Returns the key associated with a given resource. Not all the resources have a key - only those that are members of a table.- Overrides:
getKey
in classUResourceBundle
- Returns:
- a key associated to this resource, or null if it doesn't have a key
-
getNoFallback
private boolean getNoFallback()
Get the noFallback flag specified in the loaded bundle.- Returns:
- The noFallback flag.
-
getBundle
private static ICUResourceBundle getBundle(ICUResourceBundleReader reader, java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader loader)
-
getAliasedResource
protected static ICUResourceBundle getAliasedResource(ICUResourceBundle base, java.lang.String[] keys, int depth, java.lang.String key, int _resource, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
Returns the resource object referred to from the alias _resource int's path string. Throws MissingResourceException if not found. If the alias path does not contain a key path: If keys != null then keys[:depth] is used. Otherwise the base key path plus the key parameter is used.- Parameters:
base
- A direct or indirect container of the alias.keys
- The key path to the alias, or null. (const)depth
- The length of the key path, if keys != null.key
- The alias' own key within this current container, if keys == null._resource
- The alias resource int.aliasesVisited
- Set of alias path strings already visited, for detecting loops. We cannot change the type (e.g., to Set) because it is used in protected/@stable UResourceBundle methods. requested
- The original resource object from which the lookup started, which is the starting point for "/LOCALE/..." aliases.- Returns:
- the aliased resource object
-
getAliasedResource
protected static ICUResourceBundle getAliasedResource(java.lang.String rpath, java.lang.ClassLoader loaderToUse, java.lang.String baseName, java.lang.String[] keys, int depth, java.lang.String[] baseKeyPath, java.util.HashMap<java.lang.String,java.lang.String> aliasesVisited, UResourceBundle requested)
-
getTopLevelKeySet
@Deprecated public final java.util.Set<java.lang.String> getTopLevelKeySet()
Deprecated.This API is ICU internal only.
-
setTopLevelKeySet
@Deprecated public final void setTopLevelKeySet(java.util.Set<java.lang.String> keySet)
Deprecated.This API is ICU internal only.
-
handleGetKeys
protected java.util.Enumeration<java.lang.String> handleGetKeys()
Description copied from class:UResourceBundle
Actual worker method for fetching the keys of resources contained in the resource. Sub classes must override this method if they support keys and associated resources.- Overrides:
handleGetKeys
in classUResourceBundle
- Returns:
- Enumeration An enumeration of all the keys in this resource.
-
isTopLevelResource
protected boolean isTopLevelResource()
Description copied from class:UResourceBundle
Is this a top-level resource, that is, a whole bundle?- Overrides:
isTopLevelResource
in classUResourceBundle
- Returns:
- true if this is a top-level resource
-
-