org.clapper.util.misc
Class XResourceBundle

java.lang.Object
  extended by java.util.ResourceBundle
      extended by org.clapper.util.misc.XResourceBundle

public final class XResourceBundle
extends java.util.ResourceBundle

This class is an extended version of the JDK's ResourceBundle class, providing some extra methods. It can be instantiated by wrapping an existing ResourceBundle object, or by using the static getBundle() methods, which are identical to the ResourceBundle versions.

Version:
$Revision: 6687 $
Author:
Copyright © 2004-2007 Brian M. Clapper

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.ResourceBundle
java.util.ResourceBundle.Control
 
Field Summary
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
XResourceBundle(java.util.ResourceBundle bundle)
          Create a new XResourceBundle that wraps an existing ResourceBundle.
 
Method Summary
 java.util.Enumeration<java.lang.String> getKeys()
          Returns an enumeration of the keys.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Get a string for the given key from this resource bundle, applying a default if not found.
static XResourceBundle getXResourceBundle(java.lang.String baseName)
          Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.
static XResourceBundle getXResourceBundle(java.lang.String baseName, java.util.Locale locale)
          Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.
static XResourceBundle getXResourceBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader classLoader)
          Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.
protected  java.lang.Object handleGetObject(java.lang.String key)
          Gets an object for the given key from this resource bundle.
 
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
 

Constructor Detail

XResourceBundle

public XResourceBundle(java.util.ResourceBundle bundle)
Create a new XResourceBundle that wraps an existing ResourceBundle.

Parameters:
bundle - the ResourceBundle to wrap.
Method Detail

getXResourceBundle

public static XResourceBundle getXResourceBundle(java.lang.String baseName)
Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.

Parameters:
baseName - base name of the bundle to retrieve, a fully qualified class name
Returns:
the bundle
Throws:
java.lang.NullPointerException - if baseName is null
java.util.MissingResourceException - no bundle available

getXResourceBundle

public static XResourceBundle getXResourceBundle(java.lang.String baseName,
                                                 java.util.Locale locale)
Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.

Parameters:
baseName - base name of the bundle to retrieve, a fully qualified class name
locale - the locale for which a resource bundle is desired
Returns:
the bundle
Throws:
java.lang.NullPointerException - if baseName is null
java.util.MissingResourceException - no bundle available

getXResourceBundle

public static XResourceBundle getXResourceBundle(java.lang.String baseName,
                                                 java.util.Locale locale,
                                                 java.lang.ClassLoader classLoader)
Analogous to the equivalent getBundle method in the JDK's ResourceBundle class.

Parameters:
baseName - base name of the bundle to retrieve, a fully qualified class name
locale - the locale for which a resource bundle is desired
classLoader - class loader to use
Returns:
the bundle
Throws:
java.lang.NullPointerException - if baseName is null
java.util.MissingResourceException - no bundle available

getKeys

public java.util.Enumeration<java.lang.String> getKeys()
Returns an enumeration of the keys.

Specified by:
getKeys in class java.util.ResourceBundle
Returns:
the enumeration of the keys

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)
Get a string for the given key from this resource bundle, applying a default if not found. There's no equivalent for this method in the ResourceBundle class.

Parameters:
key - the key for the desired string
defaultValue - the default value, if not found
Returns:
the value for the key, which may be the default

handleGetObject

protected java.lang.Object handleGetObject(java.lang.String key)
Gets an object for the given key from this resource bundle. Returns null if this resource bundle does not contain an object for the given key.

Specified by:
handleGetObject in class java.util.ResourceBundle
Parameters:
key - the key for the desired object
Returns:
the object for the given key, or null
Throws:
java.lang.NullPointerException - if key is null


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.