com.ibm.icu.util
public abstract class UResourceBundle extends java.util.ResourceBundle
In ResourceBundle class, an object is created and the sub items are fetched using getString, getObject methods. In UResourceBundle,each individual element of a resource is a resource by itself.
Resource bundles in ICU are currently defined using text files which conform to the following BNF definition. More on resource bundle concepts and syntax can be found in the Users Guide.
The packaging of ICU *.res files can be of two types ICU4C:
root.res | -------- | | fr.res en.res | -------- | | fr_CA.res fr_FR.resJAVA/JDK:
LocaleElements.res | ------------------- | | LocaleElements_fr.res LocaleElements_en.res | --------------------------- | | LocaleElements_fr_CA.res LocaleElements_fr_FR.resDepending on the organization of your resources, the syntax to getBundleInstance will change. To open ICU style organization use:
UResourceBundle bundle = UResourceBundle.getBundleInstance("com/mycompany/resources", "en_US", myClassLoader);To open Java/JDK style organization use:
UResourceBundle bundle = UResourceBundle.getBundleInstance("com.mycompany.resources.LocaleElements", "en_US", myClassLoader);
Modifier and Type | Field and Description |
---|---|
protected static int |
ALIAS
Deprecated.
This API is ICU internal only.
|
static int |
ARRAY
Resource type constant for arrays of resources.
|
static int |
BINARY
Resource type constant for binary data.
|
static int |
INT
Resource type constant for a single 28-bit integer, interpreted as
signed or unsigned by the getInt() function.
|
static int |
INT_VECTOR
Resource type constant for vectors of 32-bit integers.
|
protected boolean |
isTopLevel
Deprecated.
This API is ICU internal only.
|
protected java.lang.String |
key
Deprecated.
This API is ICU internal only.
|
static int |
NONE
Resource type constant for "no resource".
|
protected long |
resource
Deprecated.
This API is ICU internal only.
|
protected int |
size
Deprecated.
This API is ICU internal only.
|
static int |
STRING
Resource type constant for strings.
|
static int |
TABLE
Resource type constant for tables of key-value pairs.
|
protected static int |
TABLE32
Deprecated.
This API is ICU internal only.
|
Constructor and Description |
---|
UResourceBundle()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addToCache(java.lang.ClassLoader cl,
java.lang.String fullName,
ULocale defaultLocale,
UResourceBundle b)
Deprecated.
This API is ICU internal only.
|
UResourceBundle |
get(int index)
Returns the resource in a given resource at the specified index.
|
UResourceBundle |
get(java.lang.String aKey)
Returns a resource in a given resource that has a given key.
|
protected abstract java.lang.String |
getBaseName()
Gets the base name of the resource bundle
|
java.nio.ByteBuffer |
getBinary()
Returns a binary data from a binary resource.
|
byte[] |
getBinary(byte[] ba)
Returns a binary data from a binary resource.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName)
Creates a UResourceBundle for the default locale and specified base name,
from which users can extract resources by using their corresponding keys.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
java.util.Locale locale)
Creates a UResourceBundle for the specified locale and specified base name,
from which users can extract resources by using their corresponding keys.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
java.util.Locale locale,
java.lang.ClassLoader loader)
Creates a UResourceBundle for the specified locale and specified base name,
from which users can extract resources by using their corresponding keys.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
java.lang.String localeName)
Creates a resource bundle using the specified base name and locale.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
java.lang.String localeName,
java.lang.ClassLoader root)
Creates a resource bundle using the specified base name, locale, and class root.
|
protected static UResourceBundle |
getBundleInstance(java.lang.String baseName,
java.lang.String localeName,
java.lang.ClassLoader root,
boolean disableFallback)
Creates a resource bundle using the specified base name, locale, and class root.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
ULocale locale)
Creates a UResourceBundle, from which users can extract resources by using
their corresponding keys.
|
static UResourceBundle |
getBundleInstance(java.lang.String baseName,
ULocale locale,
java.lang.ClassLoader loader)
Creates a UResourceBundle, from which users can extract resources by using
their corresponding keys.
Note: Please use this API for loading non-ICU resources. |
static UResourceBundle |
getBundleInstance(ULocale locale)
Creates a UResourceBundle for the locale specified, from which users can extract resources by using
their corresponding keys.
|
int |
getInt()
Returns a signed integer from a resource.
|
int[] |
getIntVector()
Returns a 32 bit integer array from a resource.
|
UResourceBundleIterator |
getIterator()
Returns the iterator which iterates over this
resource bundle
|
java.lang.String |
getKey()
Returns the key associated with a given resource.
|
java.util.Enumeration |
getKeys()
Returns the keys in this bundle as an enumeration
|
java.util.Locale |
getLocale()
Get the locale of this bundle
|
protected abstract java.lang.String |
getLocaleID()
Gets the localeID
|
protected abstract UResourceBundle |
getParent()
Gets the parent bundle
|
int |
getSize()
Returns the size of a resource.
|
java.lang.String |
getString()
Returns a string from a string resource type
|
java.lang.String |
getString(int index)
Returns the string in a given resource at the specified index.
|
java.lang.String[] |
getStringArray()
Returns a string array from a array resource type
|
int |
getType()
Returns the type of a resource.
|
int |
getUInt()
Returns a unsigned integer from a resource.
|
abstract ULocale |
getULocale()
Returns the RFC 3066 conformant locale id of this resource bundle.
|
VersionInfo |
getVersion()
Return the version number associated with this UResourceBundle as an
VersionInfo object.
|
protected UResourceBundle |
handleGet(int index,
java.util.HashMap table,
UResourceBundle requested)
Actual worker method for fetching a resource based on the given index.
|
protected UResourceBundle |
handleGet(java.lang.String aKey,
java.util.HashMap table,
UResourceBundle requested)
Actual worker method for fetching a resource based on the given key.
|
protected java.util.Enumeration |
handleGetKeys()
Actual worker method for fetching the keys of resources contained in the resource.
|
protected java.lang.Object |
handleGetObject(java.lang.String aKey) |
protected java.lang.String[] |
handleGetStringArray()
Actual worker method for fetching the array of strings in a resource.
|
protected static UResourceBundle |
instantiateBundle(java.lang.String baseName,
java.lang.String localeName,
java.lang.ClassLoader root,
boolean disableFallback)
Loads a new resource bundle for the give base name, locale and class loader.
|
protected static UResourceBundle |
loadFromCache(java.lang.ClassLoader cl,
java.lang.String fullName,
ULocale defaultLocale)
Deprecated.
This API is ICU internal only.
|
static void |
resetBundleCache() |
protected abstract void |
setLoadingStatus(int newStatus)
Deprecated.
This API is ICU internal only.
|
public static final int NONE
public static final int STRING
public static final int BINARY
public static final int TABLE
protected static final int ALIAS
protected static final int TABLE32
public static final int INT
getInt()
,
Constant Field Valuespublic static final int ARRAY
public static final int INT_VECTOR
getIntVector()
,
Constant Field Valuesprotected java.lang.String key
protected int size
protected long resource
protected boolean isTopLevel
public UResourceBundle()
public static UResourceBundle getBundleInstance(java.lang.String baseName, java.lang.String localeName)
baseName
- the base name of the resource bundle, a fully qualified class namelocaleName
- the locale for which a resource bundle is desiredjava.util.MissingResourceException
- if no resource bundle for the specified base name can be foundpublic static UResourceBundle getBundleInstance(java.lang.String baseName, java.lang.String localeName, java.lang.ClassLoader root)
baseName
- the base name of the resource bundle, a fully qualified class namelocaleName
- the locale for which a resource bundle is desiredroot
- the class object from which to load the resource bundlejava.util.MissingResourceException
- if no resource bundle for the specified base name can be foundprotected static UResourceBundle getBundleInstance(java.lang.String baseName, java.lang.String localeName, java.lang.ClassLoader root, boolean disableFallback)
baseName
- the base name of the resource bundle, a fully qualified class namelocaleName
- the locale for which a resource bundle is desiredroot
- the class object from which to load the resource bundledisableFallback
- Option to disable locale inheritence.
If true the fallback chain will not be built.java.util.MissingResourceException
- if no resource bundle for the specified base name can be foundpublic static UResourceBundle getBundleInstance(ULocale locale)
locale
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.public static UResourceBundle getBundleInstance(java.lang.String baseName)
baseName
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.public static UResourceBundle getBundleInstance(java.lang.String baseName, java.util.Locale locale)
baseName
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.locale
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.public static UResourceBundle getBundleInstance(java.lang.String baseName, ULocale locale)
baseName
- string containing the name of the data package.
If null the default ICU package name is used.locale
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.public static UResourceBundle getBundleInstance(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)
baseName
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.locale
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.loader
- the loader to usepublic static UResourceBundle getBundleInstance(java.lang.String baseName, ULocale locale, java.lang.ClassLoader loader)
baseName
- string containing the name of the data package.
If null the default ICU package name is used.locale
- specifies the locale for which we want to open the resource.
If null the bundle for default locale is opened.loader
- the loader to usepublic abstract ULocale getULocale()
protected abstract java.lang.String getLocaleID()
protected abstract java.lang.String getBaseName()
protected abstract UResourceBundle getParent()
public java.util.Locale getLocale()
getLocale
in class java.util.ResourceBundle
public static void resetBundleCache()
protected static void addToCache(java.lang.ClassLoader cl, java.lang.String fullName, ULocale defaultLocale, UResourceBundle b)
protected static UResourceBundle loadFromCache(java.lang.ClassLoader cl, java.lang.String fullName, ULocale defaultLocale)
protected static UResourceBundle instantiateBundle(java.lang.String baseName, java.lang.String localeName, java.lang.ClassLoader root, boolean disableFallback)
baseName
- the base name of the resource bundle, a fully qualified class namelocaleName
- the locale for which a resource bundle is desiredroot
- the class object from which to load the resource bundledisableFallback
- disables loading of fallback lookup chainjava.util.MissingResourceException
- if no resource bundle for the specified base name can be foundpublic java.nio.ByteBuffer getBinary()
java.util.MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getInt()
public java.lang.String getString()
java.util.MissingResourceException
UResourceTypeMismatchException
getBinary()
,
getIntVector()
,
getInt()
public java.lang.String[] getStringArray()
java.util.MissingResourceException
UResourceTypeMismatchException
getString()
,
getIntVector()
public byte[] getBinary(byte[] ba)
ba
- The byte array to write the bytes to. A null variable is OK.java.util.MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getInt()
public int[] getIntVector()
java.util.MissingResourceException
UResourceTypeMismatchException
getBinary()
,
getInt()
public int getInt()
java.util.MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getBinary()
public int getUInt()
java.util.MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getBinary()
public UResourceBundle get(java.lang.String aKey)
aKey
- a key associated with the wanted resourcejava.util.MissingResourceException
public java.lang.String getString(int index)
index
- an index to the wanted string.java.lang.IndexOutOfBoundsException
UResourceTypeMismatchException
public UResourceBundle get(int index)
index
- an index to the wanted resource.java.lang.IndexOutOfBoundsException
java.util.MissingResourceException
public java.util.Enumeration getKeys()
getKeys
in class java.util.ResourceBundle
public int getSize()
public int getType()
public VersionInfo getVersion()
public UResourceBundleIterator getIterator()
public java.lang.String getKey()
protected UResourceBundle handleGet(java.lang.String aKey, java.util.HashMap table, UResourceBundle requested)
aKey
- the key string of the resource to be fetchedtable
- hashtable object to hold references of resources already seenrequested
- the original resource bundle object on which the get method was invoked.
The requested bundle and the bundle on which this method is invoked
are the same, except in the cases where aliases are involved.protected UResourceBundle handleGet(int index, java.util.HashMap table, UResourceBundle requested)
index
- the index of the resource to be fetchedtable
- hashtable object to hold references of resources already seenrequested
- the original resource bundle object on which the get method was invoked.
The requested bundle and the bundle on which this method is invoked
are the same, except in the cases where aliases are involved.protected java.lang.String[] handleGetStringArray()
protected java.util.Enumeration handleGetKeys()
protected java.lang.Object handleGetObject(java.lang.String aKey)
handleGetObject
in class java.util.ResourceBundle
protected abstract void setLoadingStatus(int newStatus)
Copyright (c) 2009 IBM Corporation and others.