Package com.ibm.icu.impl
Class ICUResourceBundle
- java.lang.Object
-
- java.util.ResourceBundle
-
- com.ibm.icu.util.UResourceBundle
-
- com.ibm.icu.impl.ICUResourceBundle
-
public class ICUResourceBundle extends UResourceBundle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classICUResourceBundle.OpenTypeprotected static classICUResourceBundle.WholeBundleFields for a whole bundle, rather than any specific resource in the bundle.-
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
-
Field Summary
Fields Modifier and Type Field Description static intALIASResource type constant for aliases; internally stores a string which identifies the actual resource storing the data (can be in a different resource bundle).static intARRAY16Resource type constant for arrays with 16-bit count and values.static intFROM_DEFAULTstatic intFROM_FALLBACKstatic intFROM_LOCALEstatic intFROM_ROOTstatic StringICU_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_BRKITR_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_BUNDLEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_COLLATION_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_CURR_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic ClassLoaderICU_DATA_CLASS_LOADERThe class loader constant to be used with getBundleInstance APIprotected static StringICU_DATA_PATHDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_LANG_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_RBNF_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_REGION_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_TRANSLIT_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadstatic StringICU_ZONE_BASE_NAMEDeprecated.because not specific to resource bundles; use the ICUData constants insteadprotected static StringINSTALLED_LOCALESThe name of the resource containing the installed localesprotected StringkeyData member where the subclasses store the key.static intRES_BOGUSA resource word value that means "no resource".static intSTRING_V2Resource type constant for 16-bit Unicode strings in formatVersion 2.static intTABLE16Resource type constant for tables with 16-bit count, key offsets and values.static intTABLE32Resource type constant for tables with 32-bit count, key offsets and values.-
Fields inherited from class com.ibm.icu.util.UResourceBundle
ARRAY, BINARY, INT, INT_VECTOR, NONE, STRING, TABLE
-
Fields inherited from class java.util.ResourceBundle
parent
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedICUResourceBundle(ICUResourceBundle.WholeBundle wholeBundle)Constructor for the root table of a bundle.protectedICUResourceBundle(ICUResourceBundle container, String key)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ICUResourceBundleat(int index)ICUResourceBundleat(String key)static ICUResourceBundlecreateBundle(String baseName, String localeID, ClassLoader root)Create a bundle using a reader.booleanequals(Object other)Compares this instance with the specified object and indicates if they are equal.StringfindStringWithFallback(String path)ICUResourceBundlefindTopLevel(int index)Returns a resource in a given resource that has a given index, or null if the resource is not found.ICUResourceBundlefindTopLevel(String aKey)Returns a resource in a given resource that has a given key, or null if the resource is not found.ICUResourceBundlefindWithFallback(String path)Like getWithFallback, but returns null if the resource is not found instead of throwing an exception.protected static ICUResourceBundlegetAliasedResource(ICUResourceBundle base, String[] keys, int depth, String key, int _resource, HashMap<String,String> aliasesVisited, UResourceBundle requested)Returns the resource object referred to from the alias _resource int's path string.voidgetAllArrayItemsWithFallback(String path, ICUResource.ArraySink sink)voidgetAllTableItemsWithFallback(String path, ICUResource.TableSink sink)static Set<String>getAvailableLocaleNameSet()Return a set of the locale names supported by a collection of resource bundles.static Set<String>getAvailableLocaleNameSet(String bundlePrefix, ClassLoader loader)Return a set of the locale names supported by a collection of resource bundles.static Locale[]getAvailableLocales()Get the set of Locales installed the base bundle.static Locale[]getAvailableLocales(String baseName, ClassLoader loader)Get the set of Locales installed in the specified bundles.static ULocale[]getAvailableULocales()Get the set of ULocales installed the base bundle.static ULocale[]getAvailableULocales(String baseName, ClassLoader loader)Get the set of Locales installed in the specified bundles.protected StringgetBaseName()Returns the base name of the resource bundlestatic UResourceBundlegetBundleInstance(String baseName, ULocale locale, ICUResourceBundle.OpenType openType)static UResourceBundlegetBundleInstance(String baseName, String localeID, ClassLoader root, boolean disableFallback)static UResourceBundlegetBundleInstance(String baseName, String localeID, ClassLoader root, ICUResourceBundle.OpenType openType)static Set<String>getFullLocaleNameSet()Return a set of all the locale names supported by a collection of resource bundles.static Set<String>getFullLocaleNameSet(String bundlePrefix, ClassLoader loader)Return a set of all the locale names supported by a collection of resource bundles.static ULocalegetFunctionalEquivalent(String baseName, ClassLoader loader, String resName, String keyword, ULocale locID, boolean[] isAvailable, boolean omitDefault)Returns a functionally equivalent locale, considering keywords as well, for the specified keyword.StringgetKey()Returns the key associated with a given resource.static String[]getKeywordValues(String baseName, String keyword)Given a tree path and keyword, return a string enumeration of all possible values for that keyword.intgetLoadingStatus()Returns the loading status of a particular resource.LocalegetLocale()Returns the locale of this resource bundle.protected StringgetLocaleID()Returns the localeIDstatic Locale[]getLocaleList(ULocale[] ulocales)Convert a list of ULocales to a list of Locales.UResourceBundlegetParent()Returns the parent bundleStringgetStringWithFallback(String path)Set<String>getTopLevelKeySet()Deprecated.This API is ICU internal only.ULocalegetULocale()Returns the RFC 3066 conformant locale id of this resource bundle.ICUResourceBundlegetWithFallback(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 Enumeration<String>handleGetKeys()Actual worker method for fetching the keys of resources contained in the resource.inthashCode()Returns an integer hash code for this object.protected static UResourceBundleinstantiateBundle(String baseName, String localeID, ClassLoader root, boolean disableFallback)protected booleanisTopLevelResource()Is this a top-level resource, that is, a whole bundle?voidsetLoadingStatus(int newStatus)This method is for setting the loading status of the resource.voidsetLoadingStatus(String requestedLocale)protected voidsetParent(ResourceBundle parent)Sets the parent resource bundle of thisResourceBundle.voidsetTopLevelKeySet(Set<String> keySet)Deprecated.This API is ICU internal only.-
Methods inherited from class com.ibm.icu.util.UResourceBundle
addToCache, 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, keySet, loadFromCache, resetBundleCache
-
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray
-
-
-
-
Field Detail
-
ICU_DATA_PATH
@Deprecated protected static final String ICU_DATA_PATH
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe data path to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_BUNDLE
@Deprecated public static final String ICU_BUNDLE
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe data path to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_BASE_NAME
@Deprecated public static final String ICU_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe base name of ICU data to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_COLLATION_BASE_NAME
@Deprecated public static final String ICU_COLLATION_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe base name of collation data to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_BRKITR_BASE_NAME
@Deprecated public static final String ICU_BRKITR_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe base name of rbbi data to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_RBNF_BASE_NAME
@Deprecated public static final String ICU_RBNF_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe base name of rbnf data to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_TRANSLIT_BASE_NAME
@Deprecated public static final String ICU_TRANSLIT_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants insteadThe base name of transliterator data to be used with getBundleInstance API- See Also:
- Constant Field Values
-
ICU_LANG_BASE_NAME
@Deprecated public static final String ICU_LANG_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants instead- See Also:
- Constant Field Values
-
ICU_CURR_BASE_NAME
@Deprecated public static final String ICU_CURR_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants instead- See Also:
- Constant Field Values
-
ICU_REGION_BASE_NAME
@Deprecated public static final String ICU_REGION_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants instead- See Also:
- Constant Field Values
-
ICU_ZONE_BASE_NAME
@Deprecated public static final String ICU_ZONE_BASE_NAME
Deprecated.because not specific to resource bundles; use the ICUData constants instead- See Also:
- Constant Field Values
-
ICU_DATA_CLASS_LOADER
public static final ClassLoader ICU_DATA_CLASS_LOADER
The class loader constant to be used with getBundleInstance API
-
INSTALLED_LOCALES
protected static final String INSTALLED_LOCALES
The name of the resource containing the installed locales- See Also:
- Constant Field Values
-
FROM_FALLBACK
public static final int FROM_FALLBACK
- See Also:
- Constant Field Values
-
FROM_ROOT
public static final int FROM_ROOT
- See Also:
- Constant Field Values
-
FROM_DEFAULT
public static final int FROM_DEFAULT
- See Also:
- Constant Field Values
-
FROM_LOCALE
public static final int FROM_LOCALE
- See Also:
- Constant Field Values
-
key
protected 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
-
-
Constructor Detail
-
ICUResourceBundle
protected ICUResourceBundle(ICUResourceBundle.WholeBundle wholeBundle)
Constructor for the root table of a bundle.
-
ICUResourceBundle
protected ICUResourceBundle(ICUResourceBundle container, String key)
-
-
Method Detail
-
setLoadingStatus
public void setLoadingStatus(int newStatus)
Description copied from class:UResourceBundleThis method is for setting the loading status of the resource. The status is analogous to the warning status in ICU4C.- Specified by:
setLoadingStatusin classUResourceBundle
-
getLoadingStatus
public int getLoadingStatus()
Returns the loading status of a particular resource.- Returns:
- FROM_FALLBACK if the resource is fetched from fallback bundle FROM_ROOT if the resource is fetched from root bundle. FROM_DEFAULT if the resource is fetched from the default locale.
-
setLoadingStatus
public void setLoadingStatus(String requestedLocale)
-
getFunctionalEquivalent
public static final ULocale getFunctionalEquivalent(String baseName, ClassLoader loader, String resName, 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 String[] getKeywordValues(String baseName, 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(String path) throws 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:
MissingResourceException- If a resource was not found.
-
at
public ICUResourceBundle at(int index)
-
at
public ICUResourceBundle at(String key)
-
findTopLevel
public ICUResourceBundle findTopLevel(int index)
Description copied from class:UResourceBundleReturns a resource in a given resource that has a given index, or null if the resource is not found.- Overrides:
findTopLevelin classUResourceBundle- Parameters:
index- the index of the resource- Returns:
- the resource, or null
- See Also:
UResourceBundle.get(int)
-
findTopLevel
public ICUResourceBundle findTopLevel(String aKey)
Description copied from class:UResourceBundleReturns a resource in a given resource that has a given key, or null if the resource is not found.- Overrides:
findTopLevelin classUResourceBundle- Parameters:
aKey- the key associated with the wanted resource- Returns:
- the resource, or null
- See Also:
UResourceBundle.get(String)
-
findWithFallback
public ICUResourceBundle findWithFallback(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
-
getStringWithFallback
public String getStringWithFallback(String path) throws MissingResourceException
- Throws:
MissingResourceException
-
getAllArrayItemsWithFallback
public void getAllArrayItemsWithFallback(String path, ICUResource.ArraySink sink) throws MissingResourceException
- Throws:
MissingResourceException
-
getAllTableItemsWithFallback
public void getAllTableItemsWithFallback(String path, ICUResource.TableSink sink) throws MissingResourceException
- Throws:
MissingResourceException
-
getAvailableLocaleNameSet
public static Set<String> getAvailableLocaleNameSet(String bundlePrefix, 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 Set<String> getFullLocaleNameSet()
Return a set of all the locale names supported by a collection of resource bundles.
-
getFullLocaleNameSet
public static Set<String> getFullLocaleNameSet(String bundlePrefix, 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 Set<String> getAvailableLocaleNameSet()
Return a set of the locale names supported by a collection of resource bundles.
-
getAvailableULocales
public static final ULocale[] getAvailableULocales(String baseName, ClassLoader loader)
Get the set of Locales installed in the specified bundles.- 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
-
getAvailableLocales
public static final Locale[] getAvailableLocales(String baseName, ClassLoader loader)
Get the set of Locales installed in the specified bundles.- Returns:
- the list of available locales
-
getAvailableLocales
public static final Locale[] getAvailableLocales()
Get the set of Locales installed the base bundle.- Returns:
- the list of available locales
-
getLocaleList
public static final 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 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:
getLocalein classUResourceBundle- Returns:
- the locale of this resource bundle
-
equals
public boolean equals(Object other)
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
other- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
getBundleInstance
public static UResourceBundle getBundleInstance(String baseName, String localeID, ClassLoader root, boolean disableFallback)
-
instantiateBundle
protected static UResourceBundle instantiateBundle(String baseName, String localeID, ClassLoader root, boolean disableFallback)
-
getBundleInstance
public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ICUResourceBundle.OpenType openType)
-
getBundleInstance
public static UResourceBundle getBundleInstance(String baseName, String localeID, ClassLoader root, ICUResourceBundle.OpenType openType)
-
createBundle
public static ICUResourceBundle createBundle(String baseName, String localeID, 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 String getLocaleID()
Description copied from class:UResourceBundleReturns the localeID- Specified by:
getLocaleIDin classUResourceBundle- Returns:
- The string representation of the localeID
-
getBaseName
protected String getBaseName()
Description copied from class:UResourceBundleReturns the base name of the resource bundle- Specified by:
getBaseNamein classUResourceBundle- Returns:
- The string representation of the base name
-
getULocale
public ULocale getULocale()
Description copied from class:UResourceBundleReturns 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:
getULocalein classUResourceBundle- Returns:
- the locale of this resource bundle
-
getParent
public UResourceBundle getParent()
Description copied from class:UResourceBundleReturns the parent bundle- Specified by:
getParentin classUResourceBundle- Returns:
- The parent bundle
-
setParent
protected void setParent(ResourceBundle parent)
Description copied from class:ResourceBundleSets the parent resource bundle of thisResourceBundle. The parent is searched for resources which are not found in thisResourceBundle.- Overrides:
setParentin classResourceBundle- Parameters:
parent- the parentResourceBundle.
-
getKey
public String getKey()
Description copied from class:UResourceBundleReturns the key associated with a given resource. Not all the resources have a key - only those that are members of a table.- Overrides:
getKeyin classUResourceBundle- Returns:
- a key associated to this resource, or null if it doesn't have a key
-
getAliasedResource
protected static ICUResourceBundle getAliasedResource(ICUResourceBundle base, String[] keys, int depth, String key, int _resource, HashMap<String,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
-
getTopLevelKeySet
public final Set<String> getTopLevelKeySet()
Deprecated.This API is ICU internal only.
-
setTopLevelKeySet
public final void setTopLevelKeySet(Set<String> keySet)
Deprecated.This API is ICU internal only.
-
handleGetKeys
protected Enumeration<String> handleGetKeys()
Description copied from class:UResourceBundleActual 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:
handleGetKeysin classUResourceBundle- Returns:
- Enumeration An enumeration of all the keys in this resource.
-
isTopLevelResource
protected boolean isTopLevelResource()
Description copied from class:UResourceBundleIs this a top-level resource, that is, a whole bundle?- Overrides:
isTopLevelResourcein classUResourceBundle- Returns:
- true if this is a top-level resource
-
-