com.tivoli.twg.libs
Class MultiLocaleBundle

java.lang.Object
  extended bycom.tivoli.twg.libs.MultiLocaleBundle

public class MultiLocaleBundle
extends java.lang.Object

Class for managing and caching references to multiple languages under a single resource bundle identifier.


Constructor Summary
MultiLocaleBundle(java.lang.String bundle_name)
          Constructor for MultiLocalBundle : find and load default locale information for bundle.
 
Method Summary
 java.lang.String BundleName()
          Return bundle name
 java.util.ResourceBundle GetBundleForLocale(java.util.Locale loc)
          Get resource bundle by locale.
protected  java.util.ResourceBundle getResourceBundle(java.lang.String bundle_name, java.util.Locale defloc)
          Uses the java ResourceBundle class to find the resource bundle.
protected  java.util.ResourceBundle getResourceBundle(java.lang.String bundle_name, java.util.Locale defloc, java.lang.ClassLoader classLoader)
          Uses the java ResourceBundle class to find the resource bundle.
static MultiLocaleBundle getSharedBundle(java.lang.String bundle_name)
          Get or load shared bundle
protected static MultiLocaleBundle getSharedBundleIfExists(java.lang.String bundle_name)
          Allow a subclass to implement a getSharedBundle like method by allowing a search of the shared_bundles hash table without creating the object if it doesn't exist.
 java.lang.String getString(java.util.Locale loc, java.lang.String sname)
          Get single string from a resource for a given locale.
 java.lang.String getString(java.util.Locale loc, java.lang.String sname, java.lang.String def_val)
          Get single string from a resource for a given locale.
protected static void putSharedBundle(java.lang.String bundle_name, MultiLocaleBundle bund)
          Allows putting a bundle in the shared_bundle hastable.
static void removeSharedBundle(java.lang.String bundle_name)
          Remove bundle from shared list (encourages unload)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiLocaleBundle

public MultiLocaleBundle(java.lang.String bundle_name)
                  throws java.util.MissingResourceException
Constructor for MultiLocalBundle : find and load default locale information for bundle.

Parameters:
bundle_name - - name of base class for resource bundle
Throws:
java.util.MissingResourceException - if default bundle not found
Method Detail

GetBundleForLocale

public java.util.ResourceBundle GetBundleForLocale(java.util.Locale loc)
Get resource bundle by locale. Returns existing instances if already loaded.

Parameters:
loc - - locale of resources to be loaded
Returns:
resource bundle requested

getString

public final java.lang.String getString(java.util.Locale loc,
                                        java.lang.String sname)
                                 throws java.util.MissingResourceException
Get single string from a resource for a given locale. This should only be used an a convenience for loading single strings. For loading more than one string, use GetBundleForLocale() and then getString() on the returned ResourceBundle instance.

Parameters:
loc - - locale
sname - - string name
Returns:
string loaded,
Throws:
java.util.MissingResourceException

getString

public final java.lang.String getString(java.util.Locale loc,
                                        java.lang.String sname,
                                        java.lang.String def_val)
Get single string from a resource for a given locale. This should only be used an a convenience for loading single strings. For loading more than one string, use GetBundleForLocale() and then getString() on the returned ResourceBundle instance. A default string value can be provided, which will be used if the requested string is not found.

Parameters:
loc - - locale
sname - - string name
def_val - - default string value, if string not found
Returns:
string loaded,

BundleName

public java.lang.String BundleName()
Return bundle name

Returns:
bundle name

getSharedBundle

public static MultiLocaleBundle getSharedBundle(java.lang.String bundle_name)
                                         throws java.util.MissingResourceException
Get or load shared bundle

Parameters:
bundle_name - - name of bundle to find or load
Returns:
bundle loaded or found
Throws:
java.util.MissingResourceException - if default bundle not found

removeSharedBundle

public static void removeSharedBundle(java.lang.String bundle_name)
Remove bundle from shared list (encourages unload)

Parameters:
bundle_name - - name of bundle to be removed

getResourceBundle

protected java.util.ResourceBundle getResourceBundle(java.lang.String bundle_name,
                                                     java.util.Locale defloc)
                                              throws java.util.MissingResourceException
Uses the java ResourceBundle class to find the resource bundle. If a subclass wishes to change this behavior they would override this method.

Parameters:
bundle_name - - name of base class for resource bundle
Throws:
java.util.MissingResourceException - if default bundle not found

getResourceBundle

protected java.util.ResourceBundle getResourceBundle(java.lang.String bundle_name,
                                                     java.util.Locale defloc,
                                                     java.lang.ClassLoader classLoader)
                                              throws java.util.MissingResourceException
Uses the java ResourceBundle class to find the resource bundle. If a subclass wishes to change this behavior they would override this method.

Parameters:
bundle_name - - name of base class for resource bundle
classLoader - - load loader
Throws:
java.util.MissingResourceException - if default bundle not found

getSharedBundleIfExists

protected static MultiLocaleBundle getSharedBundleIfExists(java.lang.String bundle_name)
Allow a subclass to implement a getSharedBundle like method by allowing a search of the shared_bundles hash table without creating the object if it doesn't exist.

Parameters:
bundle_name - - name of bundle to get.
Returns:
bundle that is found

putSharedBundle

protected static void putSharedBundle(java.lang.String bundle_name,
                                      MultiLocaleBundle bund)
Allows putting a bundle in the shared_bundle hastable. The bundle would then be available to getSharedBundle and getSharedBundleIfExists.

Parameters:
bundle_name - - name of bundle
bund - - MultiLocaleBundle for bundle name