com.ibm.icu.util
public abstract class UResourceBundle extends 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.res
JAVA/JDK:
LocaleElements.res
|
-------------------
| |
LocaleElements_fr.res LocaleElements_en.res
|
---------------------------
| |
LocaleElements_fr_CA.res LocaleElements_fr_FR.res
Depending 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);
ResourceBundle.Control| 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 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.
|
parent| Constructor and Description |
|---|
UResourceBundle()
Sole constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addToCache(ClassLoader cl,
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(String aKey)
Returns a resource in a given resource that has a given key.
|
protected abstract String |
getBaseName()
Gets the base name of the resource bundle
|
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(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(String baseName,
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(String baseName,
Locale locale,
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(String baseName,
String localeName)
Creates a resource bundle using the specified base name and locale.
|
static UResourceBundle |
getBundleInstance(String baseName,
String localeName,
ClassLoader root)
Creates a resource bundle using the specified base name, locale, and class root.
|
protected static UResourceBundle |
getBundleInstance(String baseName,
String localeName,
ClassLoader root,
boolean disableFallback)
Creates a resource bundle using the specified base name, locale, and class root.
|
static UResourceBundle |
getBundleInstance(String baseName,
ULocale locale)
Creates a UResourceBundle, from which users can extract resources by using
their corresponding keys.
|
static UResourceBundle |
getBundleInstance(String baseName,
ULocale locale,
ClassLoader loader)
Creates a UResourceBundle, from which users can extract resources by using
their corresponding keys.
|
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
|
String |
getKey()
Returns the key associated with a given resource.
|
Enumeration |
getKeys()
Returns the keys in this bundle as an enumeration
|
Locale |
getLocale()
Get the locale of this bundle
|
protected abstract String |
getLocaleID()
Gets the localeID
|
protected abstract UResourceBundle |
getParent()
Gets the parent bundle
|
int |
getSize()
Returns the size of a resource.
|
String |
getString()
Returns a string from a string resource type
|
String |
getString(int index)
Returns the string in a given resource at the specified index.
|
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,
HashMap table,
UResourceBundle requested)
Actual worker method for fetching a resource based on the given index.
|
protected UResourceBundle |
handleGet(String aKey,
HashMap table,
UResourceBundle requested)
Actual worker method for fetching a resource based on the given key.
|
protected Enumeration |
handleGetKeys()
Actual worker method for fetching the keys of resources contained in the resource.
|
protected Object |
handleGetObject(String aKey) |
protected String[] |
handleGetStringArray()
Actual worker method for fetching the array of strings in a resource.
|
protected static UResourceBundle |
instantiateBundle(String baseName,
String localeName,
ClassLoader root,
boolean disableFallback)
Loads a new resource bundle for the give base name, locale and class loader.
|
protected static UResourceBundle |
loadFromCache(ClassLoader cl,
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.
|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, keySet, setParentpublic 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 String key
protected int size
protected long resource
protected boolean isTopLevel
public UResourceBundle()
public static UResourceBundle getBundleInstance(String baseName, String localeName)
baseName - the base name of the resource bundle, a fully qualified class namelocaleName - the locale for which a resource bundle is desiredMissingResourceException - if no resource bundle for the specified base name can be foundpublic static UResourceBundle getBundleInstance(String baseName, String localeName, 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 bundleMissingResourceException - if no resource bundle for the specified base name can be foundprotected static UResourceBundle getBundleInstance(String baseName, String localeName, 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.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(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(String baseName, 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(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(String baseName, Locale locale, 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(String baseName, ULocale locale, 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 String getLocaleID()
protected abstract String getBaseName()
protected abstract UResourceBundle getParent()
public Locale getLocale()
getLocale in class ResourceBundlepublic static void resetBundleCache()
protected static void addToCache(ClassLoader cl, String fullName, ULocale defaultLocale, UResourceBundle b)
protected static UResourceBundle loadFromCache(ClassLoader cl, String fullName, ULocale defaultLocale)
protected static UResourceBundle instantiateBundle(String baseName, String localeName, 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 chainMissingResourceException - if no resource bundle for the specified base name can be foundpublic ByteBuffer getBinary()
MissingResourceExceptionUResourceTypeMismatchExceptiongetIntVector(),
getInt()public String getString()
MissingResourceExceptionUResourceTypeMismatchExceptiongetBinary(),
getIntVector(),
getInt()public String[] getStringArray()
MissingResourceExceptionUResourceTypeMismatchExceptiongetString(),
getIntVector()public byte[] getBinary(byte[] ba)
ba - The byte array to write the bytes to. A null variable is OK.MissingResourceExceptionUResourceTypeMismatchExceptiongetIntVector(),
getInt()public int[] getIntVector()
MissingResourceExceptionUResourceTypeMismatchExceptiongetBinary(),
getInt()public int getInt()
MissingResourceExceptionUResourceTypeMismatchExceptiongetIntVector(),
getBinary()public int getUInt()
MissingResourceExceptionUResourceTypeMismatchExceptiongetIntVector(),
getBinary()public UResourceBundle get(String aKey)
aKey - a key associated with the wanted resourceMissingResourceExceptionpublic String getString(int index)
index - an index to the wanted string.IndexOutOfBoundsExceptionUResourceTypeMismatchExceptionpublic UResourceBundle get(int index)
index - an index to the wanted resource.IndexOutOfBoundsExceptionMissingResourceExceptionpublic Enumeration getKeys()
getKeys in class ResourceBundlepublic int getSize()
public int getType()
public VersionInfo getVersion()
public UResourceBundleIterator getIterator()
public String getKey()
protected UResourceBundle handleGet(String aKey, 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, 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 String[] handleGetStringArray()
protected Enumeration handleGetKeys()
protected Object handleGetObject(String aKey)
handleGetObject in class ResourceBundleprotected abstract void setLoadingStatus(int newStatus)
Copyright (c) 2009 IBM Corporation and others.