Package com.portal.pfc.util
Class ChainedResourceBundle
java.lang.Object
java.util.ResourceBundle
java.util.PropertyResourceBundle
com.portal.pfc.util.ChainedResourceBundle
ChainedResourceBundle allows chaining multiple resource bundles. If a
resource is not found in a bundle its parent is automatically searched
for the same resource.
- Author:
- Max Spivak
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
Field Summary
Fields inherited from class java.util.ResourceBundle
parent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceBundle
getBundle
(String res, ClassLoader classLoader) Load and return specified resource bundle using specified class loader.static ResourceBundle
getBundle
(ResourceBundle parent, String res, ClassLoader classLoader) Load and return specified resource bundle using specified class loader.static ResourceBundle
getBundle
(ResourceBundle parent, String res, Locale loc) Load and return specified resource bundle for the specified locale.static ResourceBundle
getBundle
(ResourceBundle parent, String res, Locale loc, ClassLoader classLoader) Load and return specified resource bundle for the specified locale.void
Methods inherited from class java.util.PropertyResourceBundle
getKeys, handleGetObject, handleKeySet
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet
-
Constructor Details
-
ChainedResourceBundle
- Parameters:
is
-- Throws:
IOException
-
-
Method Details
-
getBundle
public static ResourceBundle getBundle(String res, ClassLoader classLoader) throws MissingResourceException Load and return specified resource bundle using specified class loader.- Parameters:
res
- Fully-qualified name of the resource bundle, i.e.com.portal.app.someapp.MyResources
classLoader
- The classloader that should be used to load the resource bundle. In most cases it should be the caller's class loader which can be obtained by callingthis.getClass().getClassLoader()
. Value should not be null.- Returns:
- ChainedResourceBundle
- Throws:
MissingResourceException
- if the bundle can't be loaded
-
getBundle
public static ResourceBundle getBundle(ResourceBundle parent, String res, ClassLoader classLoader) throws MissingResourceException Load and return specified resource bundle using specified class loader. The specified parent resource bundle is set as the parent of the returned bundle.- Parameters:
parent
- ResourceBundle that is set as the parent of the returned bundle.res
- Fully-qualified name of the resource bundle, i.e.com.portal.app.someapp.MyResources
classLoader
- The classloader that should be used to load the resource bundle. In most cases it should be the caller's class loader which can be obtained by callingthis.getClass().getClassLoader()
. Value should not be null.- Returns:
- ChainedResourceBundle
- Throws:
MissingResourceException
- if the bundle can't be loaded
-
getBundle
public static ResourceBundle getBundle(ResourceBundle parent, String res, Locale loc) throws MissingResourceException Load and return specified resource bundle for the specified locale. The specified parent resource bundle is set as the parent of the returned bundle.- Parameters:
parent
- ResourceBundle that is set as the parent of the returned bundle.res
- Fully-qualified name of the resource bundle, i.e.com.portal.app.someapp.MyResources
loc
- The locale for which the resource bundle will be loaded.- Returns:
- ChainedResourceBundle
- Throws:
MissingResourceException
- if the bundle can't be loaded
-
getBundle
public static ResourceBundle getBundle(ResourceBundle parent, String res, Locale loc, ClassLoader classLoader) throws MissingResourceException Load and return specified resource bundle for the specified locale. Use the specified classloader to load the resource. The specified parent resource bundle is set as the parent of the returned bundle.- Parameters:
parent
- ResourceBundle that is set as the parent of the returned bundle.res
- Fully-qualified name of the resource bundle, i.e.com.portal.app.someapp.MyResources
loc
- The locale for which the resource bundle will be loaded.classLoader
- The classloader that should be used to load the resource bundle. In most cases it should be the caller's class loader which can be obtained by callingthis.getClass().getClassLoader()
. Value should not be null.- Returns:
- ChainedResourceBundle
- Throws:
MissingResourceException
- if the bundle can't be loaded
-
setParent
- Overrides:
setParent
in classResourceBundle
- Parameters:
rb
-
-
getParent
- Returns:
-