|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.ResourceBundle
com.ibm.icu.util.UResourceBundle
public abstract class UResourceBundle
A class representing a collection of resource information pertaining to a given locale. A resource bundle provides a way of accessing locale- specific information in a data file. You create a resource bundle that manages the resources for a given locale and then ask it for individual resources.
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);
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.ResourceBundle |
---|
ResourceBundle.Control |
Field Summary | |
---|---|
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. |
Fields inherited from class java.util.ResourceBundle |
---|
parent |
Constructor Summary | |
---|---|
UResourceBundle()
Sole constructor. |
Method Summary | |
---|---|
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. |
protected abstract void |
setLoadingStatus(int newStatus)
Deprecated. This API is ICU internal only. |
Methods inherited from class java.util.ResourceBundle |
---|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, keySet, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 String key
protected int size
protected long resource
protected boolean isTopLevel
Constructor Detail |
---|
public UResourceBundle()
Method Detail |
---|
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 desired
MissingResourceException
- 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 bundle
MissingResourceException
- 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 use
public 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 use
public abstract ULocale getULocale()
protected abstract String getLocaleID()
protected abstract String getBaseName()
protected abstract UResourceBundle getParent()
public Locale getLocale()
getLocale
in class ResourceBundle
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 chain
MissingResourceException
- if no resource bundle for the specified base name can be foundpublic ByteBuffer getBinary()
MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getInt()
public String getString()
MissingResourceException
UResourceTypeMismatchException
getBinary()
,
getIntVector()
,
getInt()
public String[] getStringArray()
MissingResourceException
UResourceTypeMismatchException
getString()
,
getIntVector()
public byte[] getBinary(byte[] ba)
ba
- The byte array to write the bytes to. A null variable is OK.
MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getInt()
public int[] getIntVector()
MissingResourceException
UResourceTypeMismatchException
getBinary()
,
getInt()
public int getInt()
MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getBinary()
public int getUInt()
MissingResourceException
UResourceTypeMismatchException
getIntVector()
,
getBinary()
public UResourceBundle get(String aKey)
aKey
- a key associated with the wanted resource
MissingResourceException
public String getString(int index)
index
- an index to the wanted string.
IndexOutOfBoundsException
UResourceTypeMismatchException
public UResourceBundle get(int index)
index
- an index to the wanted resource.
IndexOutOfBoundsException
MissingResourceException
public Enumeration getKeys()
getKeys
in class ResourceBundle
public int getSize()
public int getType()
INT
, ARRAY
,
BINARY
, INT_VECTOR
,
STRING
, TABLE
.
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 ResourceBundle
protected abstract void setLoadingStatus(int newStatus)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |