public class CommonGlobalProvider extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COMMON_RESOURCES
Location of common resource package
|
Constructor and Description |
---|
CommonGlobalProvider() |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String COMMON_RESOURCES
public static String localize(String resBundle, String messageKey, Object[] args, ClassLoader loader)
resBundle
- resource bundlemessageKey
- the message keyargs
- object array of argumentsloader
- class loaderpublic static ResourceBundle getResourceBundle(String clazz, ClassLoader loader)
clazz
- loader
- public static ResourceBundle getResourceBundle(String clazz)
clazz
- public static String format(ResourceBundle resourceBundle, String messageKey, Object[] args)
resourceBundle
- the resource bundle containing the stringmessageKey
- the key in the resource bundleargs
- the arguments to used to format the resource stringpublic static String localizeTemplate(String template, Locale locale, ClassLoader loader, String defaultBundleName)
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.