Package org.pentaho.di.i18n
Class GlobalMessages
- java.lang.Object
-
- org.pentaho.di.i18n.AbstractMessageHandler
-
- org.pentaho.di.i18n.GlobalMessages
-
- All Implemented Interfaces:
MessageHandler,Handler
- Direct Known Subclasses:
LAFMessageHandler
public class GlobalMessages extends AbstractMessageHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringBUNDLE_NAMEprotected static GlobalMessagesGMinstancestatic String[]localeCodesstatic String[]localeDescrprotected static Map<String,ResourceBundle>localesprotected static LogChannelInterfacelogprotected static Class<?>PKGprotected static StringSYSTEM_BUNDLE_PACKAGE
-
Constructor Summary
Constructors Constructor Description GlobalMessages()TODO: extend from abstract class to ensure singleton status and migrate instantiation to class controlled private
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static StringbuildBundleName(String packageName)protected StringcalculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass)Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameandBUNDLE_NAME(the first valid combination ofpackageName+BUNDLE_NAMEwins), sing the providedresourceClass's class loader.protected StringcalculateString(String packageName, String key, Object[] parameters)Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using theGlobalMessagesclass loader.protected StringcalculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using the providedresourceClass's class loader.static ResourceBundlegetBundle(String packageName)Retrieve a resource bundle of the default or fail-over locale.static MessageHandlergetInstance()protected static Map<String,ResourceBundle>getLocales()StringgetString(String key)get a key from the default (System global) bundleStringgetString(String packageName, String key)get a key from the defined package bundle, by keyStringgetString(String packageName, String key, Class<?> resourceClass, String... parameters)Get a string from the defined package bundle, by key and by a resource classStringgetString(String packageName, String key, String... parameters)get a key from the defined package bundle, by key-
Methods inherited from class org.pentaho.di.i18n.AbstractMessageHandler
getLocale, setLocale
-
-
-
-
Field Detail
-
PKG
protected static Class<?> PKG
-
SYSTEM_BUNDLE_PACKAGE
protected static final String SYSTEM_BUNDLE_PACKAGE
-
BUNDLE_NAME
protected static final String BUNDLE_NAME
- See Also:
- Constant Field Values
-
locales
protected static final Map<String,ResourceBundle> locales
-
log
protected static final LogChannelInterface log
-
localeCodes
public static final String[] localeCodes
-
localeDescr
public static final String[] localeDescr
-
GMinstance
protected static GlobalMessages GMinstance
-
-
Method Detail
-
getInstance
public static MessageHandler getInstance()
-
getLocales
protected static Map<String,ResourceBundle> getLocales()
-
getBundle
public static ResourceBundle getBundle(String packageName) throws MissingResourceException
Retrieve a resource bundle of the default or fail-over locale.- Parameters:
packageName- The package to search in- Returns:
- The resource bundle
- Throws:
MissingResourceException- in case both resource bundles couldn't be found.
-
calculateString
protected String calculateString(String packageName, String key, Object[] parameters)
Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using theGlobalMessagesclass loader.- Parameters:
packageName- the package containing the localized messageskey- the message key being looked upparameters- parameters within the looked up message- Returns:
- the localized string for the given
keyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using theGlobalMessagesclass loader.
-
calculateString
protected String calculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)
Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using the providedresourceClass's class loader.- Parameters:
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 bundle- Returns:
- the localized string for the given
keyandparametersin a bundle defined by the the concatenation ofpackageNameandBUNDLE_NAME, using the providedresourceClass's class loader.
-
calculateString
protected String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass)
Returns the localized string for the givenkeyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameandBUNDLE_NAME(the first valid combination ofpackageName+BUNDLE_NAMEwins), sing the providedresourceClass's class loader.- Parameters:
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 bundle- Returns:
- the localized string for the given
keyandparametersin a bundle defined by the the concatenation of the package names defined inpackageNameandBUNDLE_NAME(the first valid combination ofpackageName+BUNDLE_NAMEwins), sing the providedresourceClass's class loader
-
getString
public String getString(String key)
Description copied from interface:MessageHandlerget a key from the default (System global) bundle- Returns:
-
getString
public String getString(String packageName, String key)
Description copied from interface:MessageHandlerget a key from the defined package bundle, by key- Returns:
-
getString
public String getString(String packageName, String key, String... parameters)
Description copied from interface:MessageHandlerget a key from the defined package bundle, by key- Returns:
-
-