com.webmethods.caf.common
Class CommonGlobalProvider

java.lang.Object
  extended by com.webmethods.caf.common.CommonGlobalProvider

public class CommonGlobalProvider
extends Object

This class is meant to provide the common resource bundle with a localized format based on the end users needs.


Field Summary
static String COMMON_RESOURCES
          Location of common resource package
 
Constructor Summary
CommonGlobalProvider()
           
 
Method Summary
static String format(ResourceBundle resourceBundle, String messageKey, Object[] args)
          Format a string from a resource bundle key with arguments
static ResourceBundle getResourceBundle(String clazz)
          Get resource bundle based on class input
static ResourceBundle getResourceBundle(String clazz, ClassLoader loader)
          Get resource bundle based on class and loader types.
static String localize(String resBundle, String messageKey, Object[] args, ClassLoader loader)
          Localize the bundle using arguments and specific loaders
static String localizeTemplate(String template, Locale locale, ClassLoader loader, String defaultBundleName)
          Replaces tokens in a template with resolved resource-bundle strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMON_RESOURCES

public static final String COMMON_RESOURCES
Location of common resource package

See Also:
Constant Field Values
Constructor Detail

CommonGlobalProvider

public CommonGlobalProvider()
Method Detail

localize

public static String localize(String resBundle,
                              String messageKey,
                              Object[] args,
                              ClassLoader loader)
Localize the bundle using arguments and specific loaders

Parameters:
resBundle - resource bundle
messageKey - the message key
args - object array of arguments
loader - class loader
Returns:
localized string

getResourceBundle

public static ResourceBundle getResourceBundle(String clazz,
                                               ClassLoader loader)
Get resource bundle based on class and loader types.

Parameters:
clazz -
loader -
Returns:

getResourceBundle

public static ResourceBundle getResourceBundle(String clazz)
Get resource bundle based on class input

Parameters:
clazz -
Returns:

format

public static String format(ResourceBundle resourceBundle,
                            String messageKey,
                            Object[] args)
Format a string from a resource bundle key with arguments

Parameters:
resourceBundle - the resource bundle containing the string
messageKey - the key in the resource bundle
args - the arguments to used to format the resource string
Returns:
the formatted resource string

localizeTemplate

public static String localizeTemplate(String template,
                                      Locale locale,
                                      ClassLoader loader,
                                      String defaultBundleName)
Replaces tokens in a template with resolved resource-bundle strings. Tokens are in the form of "{bundle.class.name#resource.key}", like "{com.webmethods.portal.foo.Resources#foo.bar.label}"; or "{#foo.bar.label}" if using the specified default-bundle.

Parameters:
template - Template containing tokens to localize.
locale - Locale with which to localize.
loader - Class loader to use to load resource bundles.
defaultBundleName - Bundle to use if token doesn't specify bundle.
Returns:
Localized string.