public class GlobalMessages extends AbstractMessageHandler
Modifier and Type | Field and Description |
---|---|
protected static String |
BUNDLE_NAME |
protected static GlobalMessages |
GMinstance |
static String[] |
localeCodes |
static String[] |
localeDescr |
protected static Map<String,ResourceBundle> |
locales |
protected static LogChannelInterface |
log |
protected static Class<?> |
PKG |
protected static String |
SYSTEM_BUNDLE_PACKAGE |
Constructor and Description |
---|
GlobalMessages()
TODO: extend from abstract class to ensure singleton status and migrate instantiation to class controlled private
|
Modifier and Type | Method and Description |
---|---|
protected static String |
buildBundleName(String packageName) |
protected String |
calculateString(String[] pkgNames,
String key,
Object[] parameters,
Class<?> resourceClass)
Returns the localized string for the given
key and parameters in a bundle defined by the the
concatenation of the package names defined in packageName and BUNDLE_NAME (the first valid
combination of packageName + BUNDLE_NAME wins), sing the provided resourceClass 's class
loader. |
protected String |
calculateString(String packageName,
String key,
Object[] parameters)
Returns the localized string for the given
key and parameters in a bundle defined by the the
concatenation of packageName and BUNDLE_NAME , using the GlobalMessages class loader. |
protected String |
calculateString(String packageName,
String key,
Object[] parameters,
Class<?> resourceClass)
Returns the localized string for the given
key and parameters in a bundle defined by the the
concatenation of packageName and BUNDLE_NAME , using the provided resourceClass 's class
loader. |
static ResourceBundle |
getBundle(String packageName)
Retrieve a resource bundle of the default or fail-over locale.
|
static MessageHandler |
getInstance() |
protected static Map<String,ResourceBundle> |
getLocales() |
String |
getString(String key)
get a key from the default (System global) bundle
|
String |
getString(String packageName,
String key)
get a key from the defined package bundle, by key
|
String |
getString(String packageName,
String key,
Class<?> resourceClass,
String... parameters)
Get a string from the defined package bundle, by key and by a resource class
|
String |
getString(String packageName,
String key,
String... parameters)
get a key from the defined package bundle, by key
|
getLocale, setLocale
protected static Class<?> PKG
protected static final String SYSTEM_BUNDLE_PACKAGE
protected static final String BUNDLE_NAME
protected static final Map<String,ResourceBundle> locales
protected static final LogChannelInterface log
public static final String[] localeCodes
public static final String[] localeDescr
protected static GlobalMessages GMinstance
public GlobalMessages()
public static MessageHandler getInstance()
protected static Map<String,ResourceBundle> getLocales()
public static ResourceBundle getBundle(String packageName) throws MissingResourceException
packageName
- The package to search inMissingResourceException
- in case both resource bundles couldn't be found.protected String calculateString(String packageName, String key, Object[] parameters)
key
and parameters
in a bundle defined by the the
concatenation of packageName
and BUNDLE_NAME
, using the GlobalMessages
class loader.packageName
- the package containing the localized messageskey
- the message key being looked upparameters
- parameters within the looked up messagekey
and parameters
in a bundle defined by the the
concatenation of packageName
and BUNDLE_NAME
, using the GlobalMessages
class loader.protected String calculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)
key
and parameters
in a bundle defined by the the
concatenation of packageName
and BUNDLE_NAME
, using the provided resourceClass
's class
loader.packageName
- the package containing the localized messageskey
- the message key being looked upparameters
- parameters within the looked up messageresourceClass
- the class whose class loader is used to getch the resource bundlekey
and parameters
in a bundle defined by the the
concatenation of packageName
and BUNDLE_NAME
, using the provided resourceClass
's class
loader.protected String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass)
key
and parameters
in a bundle defined by the the
concatenation of the package names defined in packageName
and BUNDLE_NAME
(the first valid
combination of packageName
+ BUNDLE_NAME
wins), sing the provided resourceClass
's class
loader.pkgNames
- an array of packages potentially containing the localized messages the first one found to
contain the messages is the one that is used to localize the messagekey
- the message key being looked upparameters
- parameters within the looked up messageresourceClass
- the class whose class loader is used to getch the resource bundlekey
and parameters
in a bundle defined by the the
concatenation of the package names defined in packageName
and BUNDLE_NAME
(the first valid
combination of packageName
+ BUNDLE_NAME
wins), sing the provided resourceClass
's class
loaderpublic String getString(String key)
MessageHandler
public String getString(String packageName, String key)
MessageHandler
public String getString(String packageName, String key, String... parameters)
MessageHandler
Copyright © 2019 Hitachi Vantara. All rights reserved.