borland Packages Class Hierarchy jb.util Package
java.lang.Object +----java.util.ResourceBundle +----com.borland.jb.util.ArrayResourceBundle
Variables Properties MethodsThe
ArrayResourceBundle
is an abstract subclass of
java.util.ResourceBundle
that manages locale-dependent resources in an array. By using numeric references rather than string references, it requires less overhead and provides better performance than java.util.PropertyResourceBundle
and java.util.ListResourceBundle
Subclasses must override the getContents()
method and provide an array, where each item in the array is the resource value. The key for each resource value is its numeric offset in the array. For example, the first element in the array has the key 0. It may be retrieved by using either getObject(0)
or getObject("0")
.
Unlike ListResourceBundle
and PropertyResourceBundle
, where each locale-specific variation of a bundle can override only selected resources,
each variation of ArrayResourceBundle
must provide the complete
set of resources. For example, if the custom class MyResources
has three resources, then its subclasses MyResources_ja
and MyResources_fr
must also have three resources.
The following example shows the structure of a ResourceBundle
based on ArrayResourceBundle
.
class MyResource extends ArrayResourceBundle {
public Object []getContents() {
return contents;
}
static final Object []contents = {
// LOCALIZE THIS
"Yes", // Label for the YES button
"No", // Label for the NO button
"Cancel" // Label for the CANCEL button
// END OF MATERIAL TO LOCALIZE
};
}
public Enumeration getKeys()Returns an enumeration of the keys.
java.util.ResourceBundle.getKeys()
protected abstract Object[] getContents()Gets the contents of the array. See "About the ArrayResourceBundle class" for more information.
public Object getObject(int index)Gets an element in the array. If
index
is 0, the first element in the array is retrieved.
index
public final String getString(int key)Gets an object from an
ArrayResourceBundle
. This is a convenience method that saves the extra step of casting by returning a String
.
If an error occurrs, getString(int)
throws a MissingResourceException
.
key
public final String[] getStringArray(int key)Gets an object from a
ResourceBundle
. This is a convenience method that saves the extra step of casting by returning a String
.
If an error occurrs, getStringArray(int)
throws a MissingResourceException
.
key
protected Object handleGetObject(String key)Gets an object from a
ResourceBundle
. If the specified key is not found, handleGetObject
must return null.
key