|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.ResourceBundle
com.calitha.resource.XMLResourceBundle
public class XMLResourceBundle
The XMLResourceBundle is used to support resources specified in XML format. The XMLResourceBundle can be instantiated in two ways: (1) By using the classic ResourceBundle class with the static getBundle method and pass the XMLResourceBundleControl to it. (2) By using the static getResourceBundle method in this class. This second way is preferable, because you will get an object of the XMLResourceBundle class directly and it's easier to write anyway.
The resources that you get by calling the getObject method are always IResource objects. Therefore never use the getString methods! Unfortunately those methods could not be overridden, because they are final. It is advisable to use the methods declared in this class to retrieve resources. They can use namespaces, can return IResource objects, let you get the resource content as text directly, and you can specify a default text value.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.ResourceBundle |
|---|
ResourceBundle.Control |
| Field Summary | |
|---|---|
protected Map<String,IResource> |
map
|
| Fields inherited from class java.util.ResourceBundle |
|---|
parent |
| Method Summary | |
|---|---|
Enumeration<String> |
getKeys()
|
IResource |
getResource(String id)
Requests a resource from the bundle. |
IResource |
getResource(String namespace,
String id)
Requests a resource from the bundle. |
static XMLResourceBundle |
getResourceBundle(String baseName)
Gets a resourcebundle which is parsed from an XML file. |
static XMLResourceBundle |
getResourceBundle(String baseName,
Locale locale)
Gets a resourcebundle which is parsed from an XML file. |
static XMLResourceBundle |
getResourceBundle(String baseName,
Locale locale,
ClassLoader loader)
Gets a resourcebundle which is parsed from an XML file. |
String |
getText(String id)
Requests the text content of a resource from the bundle. |
String |
getText(String namespace,
String id)
Requests the text content of a resource from the bundle. |
String |
getTextDefault(String id,
String fallback)
Requests the text content of a resource from the bundle. |
String |
getTextDefault(String namespace,
String id,
String fallback)
Requests the text content of a resource from the bundle. |
protected Object |
handleGetObject(String key)
|
| Methods inherited from class java.util.ResourceBundle |
|---|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, 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 |
|---|
protected Map<String,IResource> map
| Method Detail |
|---|
public Enumeration<String> getKeys()
getKeys in class ResourceBundleprotected Object handleGetObject(String key)
handleGetObject in class ResourceBundle
public IResource getResource(String namespace,
String id)
IXMLResourceBundleThis method works similar as the getObject method, but casts the object to an IResource.
getResource in interface IXMLResourceBundlenamespace - namespaceid - id
ResourceBundle.getObject(java.lang.String)public IResource getResource(String id)
IXMLResourceBundleThis method always uses an empty namespace. This method works similar as the getObject method, but casts the object to an IResource.
getResource in interface IXMLResourceBundleid - id
ResourceBundle.getObject(java.lang.String)
public String getText(String namespace,
String id)
IXMLResourceBundle
getText in interface IXMLResourceBundlenamespace - namespaceid - id
getResource(java.lang.String, java.lang.String)public String getText(String id)
IXMLResourceBundleThis method always uses an empty namespace.
getText in interface IXMLResourceBundleid - id
getResource(java.lang.String, java.lang.String)
public String getTextDefault(String namespace,
String id,
String fallback)
IXMLResourceBundleThe default fallback string is returned if the resource cannot be found.
getTextDefault in interface IXMLResourceBundlenamespace - namespaceid - idfallback - fallback text
getResource(java.lang.String, java.lang.String)
public String getTextDefault(String id,
String fallback)
IXMLResourceBundleAlways uses an empty namespace. The default fallback string is returned if the resource cannot be found.
getTextDefault in interface IXMLResourceBundleid - idfallback - fallback text
getResource(java.lang.String, java.lang.String)public static XMLResourceBundle getResourceBundle(String baseName)
baseName - the base name of the resource bundle,
a fully qualified class name
IllegalArgumentException - if an argument is nullResourceBundle.getBundle(String)
public static XMLResourceBundle getResourceBundle(String baseName,
Locale locale)
baseName - the base name of the resource bundle,
a fully qualified class namelocale - the locale for which a resource bundle is desired
IllegalArgumentException - if an argument is nullResourceBundle.getBundle(String, Locale)
public static XMLResourceBundle getResourceBundle(String baseName,
Locale locale,
ClassLoader loader)
baseName - the base name of the resource bundle,
a fully qualified class namelocale - the locale for which a resource bundle is desiredloader - the class loader from which to load the resource bundle
IllegalArgumentException - if an argument is nullResourceBundle.getBundle(String, Locale, ClassLoader)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||