com.calitha.resource
Class XMLResourceBundleControl
java.lang.Object
java.util.ResourceBundle.Control
com.calitha.resource.XMLResourceBundleControl
public class XMLResourceBundleControl
- extends ResourceBundle.Control
The XMLResourceBundleControl is used to support resource bundles
in a custom XML format using the new control in Java 1.6.
This control can be used when getting a bundle.
Example:
ResourceBundle.getBundle(baseName,
locale,
new XMLResourceBundleControl());
- Author:
- Robert van Loenhout
- See Also:
XMLResourceBundle
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XMLResourceBundleControl
public XMLResourceBundleControl()
getFormats
public List<String> getFormats(String baseName)
- Returns XML as a supported format.
- Overrides:
getFormats in class ResourceBundle.Control
- Parameters:
baseName - the base name of the resource bundle, a fully qualified class
name
- Returns:
- list with XML format
newBundle
public ResourceBundle newBundle(String baseName,
Locale locale,
String format,
ClassLoader loader,
boolean reload)
throws IllegalAccessException,
InstantiationException,
IOException
- Gets a new XMLResourceBundle objects by parsing the XML file
at a location determined by the baseName and locale.
- Overrides:
newBundle in class ResourceBundle.Control
- Parameters:
baseName - the base name of the resource bundle,
a fully qualified class namelocale - the locale for which a resource bundle is desiredformat - the resource bundle format to be loadedloader - the ClassLoader to use to load the bundlereload - the flag to indicate bundle reloading;
true if reloading an expired resource bundle, false otherwise
- Returns:
- XMLResourceBundle instance, or null if none could be found
- Throws:
IllegalAccessException - if format is unknown, or if the resource
found for the given parameters contains
malformed data
InstantiationException - if the instantiation of a class fails for
some other reason
IOException - if an error occurred when reading resources using
any I/O operations
IllegalArgumentException - if an argument is null
getFallbackLocale
public Locale getFallbackLocale(String baseName,
Locale locale)
- No fallback locale is used, because they are undesired for most application.
Server software should not depend on the locale that has been set on that server.
- Overrides:
getFallbackLocale in class ResourceBundle.Control
- Parameters:
baseName - the base name of the resource bundle, a fully qualified
class name for which ResourceBundle.getBundle has been unable to find
any resource bundles (except for the base bundle)locale - a Locale for the fallback search, or null if no further
fallback search is desired.
- Returns:
- alyways returns null, so that the base bundle is used