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.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);
ResourceBundle.Control
Modifier and Type | Field and Description |
---|---|
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.
|
static int |
NONE
Resource type constant for "no resource".
|
static int |
STRING
Resource type constant for strings.
|
static int |
TABLE
Resource type constant for tables of key-value pairs.
|
Constructor and Description |
---|
UResourceBundle()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
UResourceBundle |
get(String aKey)
Returns a resource in a given resource that has a given key.
|
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.
|
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.
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.
|
String |
getKey()
Returns the key associated with a given resource.
|
Locale |
getLocale()
Get the locale of this bundle
|
int |
getSize()
Returns the size of a resource.
|
String |
getString()
Returns a string from a string resource type
|
String[] |
getStringArray()
Returns a string array from a array resource type
|
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.
|
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getKeys, getObject, getString, getStringArray, keySet
public static final int NONE
public static final int STRING
public static final int BINARY
public static final int TABLE
public static final int INT
getInt()
,
Constant Field Valuespublic static final int ARRAY
public static final int INT_VECTOR
getIntVector()
,
Constant Field Valuespublic 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 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()
public Locale getLocale()
getLocale
in class ResourceBundle
public 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 resourceMissingResourceException
public int getSize()
public VersionInfo getVersion()
public String getKey()
Copyright © 2010 - 2020 Adobe. All Rights Reserved