Package com.webmethods.caf.common
Class CommonGlobalProvider
java.lang.Object
com.webmethods.caf.common.CommonGlobalProvider
This class is meant to provide the common resource bundle with a localized format based on the end users needs.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
format
(ResourceBundle resourceBundle, String messageKey, Object[] args) Format a string from a resource bundle key with argumentsstatic ResourceBundle
getResourceBundle
(String clazz) Get resource bundle based on class inputstatic 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 loadersstatic String
localizeTemplate
(String template, Locale locale, ClassLoader loader, String defaultBundleName) Replaces tokens in a template with resolved resource-bundle strings.
-
Field Details
-
COMMON_RESOURCES
Location of common resource package- See Also:
-
-
Constructor Details
-
CommonGlobalProvider
public CommonGlobalProvider()
-
-
Method Details
-
localize
public static String localize(String resBundle, String messageKey, Object[] args, ClassLoader loader) Localize the bundle using arguments and specific loaders- Parameters:
resBundle
- resource bundlemessageKey
- the message keyargs
- object array of argumentsloader
- class loader- Returns:
- localized string
-
getResourceBundle
Get resource bundle based on class and loader types.- Parameters:
clazz
-loader
-- Returns:
-
getResourceBundle
Get resource bundle based on class input- Parameters:
clazz
-- Returns:
-
format
Format a string from a resource bundle key with arguments- Parameters:
resourceBundle
- the resource bundle containing the stringmessageKey
- the key in the resource bundleargs
- 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.
-