atg.core.util
Class ResourceUtils

java.lang.Object
  extended by atg.core.util.ResourceUtils

public class ResourceUtils
extends java.lang.Object

Utilities for using resource bundles.

The getBundle() calls cache the requested bundles hashed off of the Locale and the bundle basename. This will provide a speed-up over ResourceBundle.getBundle() for components that are doing many getBundle() calls, turning a series of String concatenations into two Hashtable look-ups.

The getMsgResource() calls prepend the resource string with an identifying string consisting of the bundle name and the resource look-up key. When messages are localized, it is useful to be able to identify where they came from.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static boolean useBundlePrefix
           
 
Constructor Summary
ResourceUtils()
          Empty constructor.
 
Method Summary
static java.util.ResourceBundle getBundle(java.lang.String pBaseName)
          Returns the requested ResourceBundle.
static java.util.ResourceBundle getBundle(java.lang.String pBaseName, java.util.Locale pLocale)
          Returns the requested ResourceBundle for the specified Locale.
static java.lang.String getMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle)
          Fetches the message resource from the given bundle and pre-pends the resource ID string to the message.
static java.lang.String getMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle, java.lang.Object pMsgArg)
          Fetches the message resource from the given bundle and pre-pends the resource ID string to the message.
static java.lang.String getMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle, java.lang.Object[] pMsgArgs)
          Fetches the message resource from the given bundle and pre-pends the resource ID string to the message.
static java.lang.String getMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle, java.lang.Object pMsgArg1, java.lang.Object pMsgArg2)
          Fetches the message resource from the given bundle and pre-pends the resource ID string to the message.
static java.lang.String getUserMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle)
          Fetches the message resource from the given bundle without prepending the resource ID string to the message.
static java.lang.String getUserMsgResource(java.lang.String pLookupKey, java.lang.String pBundleName, java.util.ResourceBundle pBundle, java.lang.Object[] pMsgArgs)
          Fetches the message resource from the given bundle without prepending the resource ID string to the message.
static void setUseBundlePrefix(boolean pUseBundlePrefix)
          Should we display messages using the bundle name and resource key as a prefix or just display the messages?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


useBundlePrefix

public static boolean useBundlePrefix
Constructor Detail

ResourceUtils

public ResourceUtils()
Empty constructor.

Method Detail

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String pBaseName)
                                          throws java.util.MissingResourceException
Returns the requested ResourceBundle.

Throws:
java.util.MissingResourceException

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String pBaseName,
                                                 java.util.Locale pLocale)
                                          throws java.util.MissingResourceException
Returns the requested ResourceBundle for the specified Locale.

Throws:
java.util.MissingResourceException

getMsgResource

public static java.lang.String getMsgResource(java.lang.String pLookupKey,
                                              java.lang.String pBundleName,
                                              java.util.ResourceBundle pBundle)
Fetches the message resource from the given bundle and pre-pends the resource ID string to the message.


getMsgResource

public static java.lang.String getMsgResource(java.lang.String pLookupKey,
                                              java.lang.String pBundleName,
                                              java.util.ResourceBundle pBundle,
                                              java.lang.Object[] pMsgArgs)
Fetches the message resource from the given bundle and pre-pends the resource ID string to the message. Additionally, the supplied arguments are filled into the message using MessageFormat.


getMsgResource

public static java.lang.String getMsgResource(java.lang.String pLookupKey,
                                              java.lang.String pBundleName,
                                              java.util.ResourceBundle pBundle,
                                              java.lang.Object pMsgArg)
Fetches the message resource from the given bundle and pre-pends the resource ID string to the message. Additionally, the supplied arguments are filled into the message using MessageFormat.


getMsgResource

public static java.lang.String getMsgResource(java.lang.String pLookupKey,
                                              java.lang.String pBundleName,
                                              java.util.ResourceBundle pBundle,
                                              java.lang.Object pMsgArg1,
                                              java.lang.Object pMsgArg2)
Fetches the message resource from the given bundle and pre-pends the resource ID string to the message. Additionally, the supplied arguments are filled into the message using MessageFormat.


setUseBundlePrefix

public static void setUseBundlePrefix(boolean pUseBundlePrefix)
Should we display messages using the bundle name and resource key as a prefix or just display the messages?


getUserMsgResource

public static java.lang.String getUserMsgResource(java.lang.String pLookupKey,
                                                  java.lang.String pBundleName,
                                                  java.util.ResourceBundle pBundle)
Fetches the message resource from the given bundle without prepending the resource ID string to the message. Use this to construct messages that will be shown to the end-user, e.g., messages used to construct droplet exceptions.


getUserMsgResource

public static java.lang.String getUserMsgResource(java.lang.String pLookupKey,
                                                  java.lang.String pBundleName,
                                                  java.util.ResourceBundle pBundle,
                                                  java.lang.Object[] pMsgArgs)
Fetches the message resource from the given bundle without prepending the resource ID string to the message. Additionally, the supplied arguments are filled into the message using MessageFormat.