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 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 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 String
buildBundleName(String packageName)
protected String
calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass)
Returns the localized string for the givenkey
andparameters
in a bundle defined by the the concatenation of the package names defined inpackageName
andBUNDLE_NAME
(the first valid combination ofpackageName
+BUNDLE_NAME
wins), sing the providedresourceClass
's class loader.protected String
calculateString(String packageName, String key, Object[] parameters)
Returns the localized string for the givenkey
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_NAME
, using theGlobalMessages
class loader.protected String
calculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)
Returns the localized string for the givenkey
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_NAME
, using the providedresourceClass
'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) bundleString
getString(String packageName, String key)
get a key from the defined package bundle, by keyString
getString(String packageName, String key, Class<?> resourceClass, String... parameters)
Get a string from the defined package bundle, by key and by a resource classString
getString(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 givenkey
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_NAME
, using theGlobalMessages
class 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
key
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_NAME
, using theGlobalMessages
class loader.
-
calculateString
protected String calculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)
Returns the localized string for the givenkey
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_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
key
andparameters
in a bundle defined by the the concatenation ofpackageName
andBUNDLE_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 givenkey
andparameters
in a bundle defined by the the concatenation of the package names defined inpackageName
andBUNDLE_NAME
(the first valid combination ofpackageName
+BUNDLE_NAME
wins), 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
key
andparameters
in a bundle defined by the the concatenation of the package names defined inpackageName
andBUNDLE_NAME
(the first valid combination ofpackageName
+BUNDLE_NAME
wins), sing the providedresourceClass
's class loader
-
getString
public String getString(String key)
Description copied from interface:MessageHandler
get a key from the default (System global) bundle- Returns:
-
getString
public String getString(String packageName, String key)
Description copied from interface:MessageHandler
get a key from the defined package bundle, by key- Returns:
-
getString
public String getString(String packageName, String key, String... parameters)
Description copied from interface:MessageHandler
get a key from the defined package bundle, by key- Returns:
-
-