Package org.teiid.core
Class BundleUtil
- java.lang.Object
-
- org.teiid.core.BundleUtil
-
public class BundleUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BundleUtil.Event
-
Constructor Summary
Constructors Constructor Description BundleUtil(String pluginId, String bundleName, ResourceBundle bundle)
Construct an instance of this class by specifying the plugin ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BundleUtil
getBundleUtil(Class<?> clazz)
Return theBundleUtil
for the class.String
getString(String key)
Get the string identified by the given key and localized to the current locale.String
getString(String key, Object... parameters)
Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.String
getString(String key, List parameters)
Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.String
getStringOrKey(String key)
String
gs(String key, Object... parameters)
String
gs(BundleUtil.Event key, Object... parameters)
boolean
keyExists(String key)
Determines if the given key exists in the resource file.
-
-
-
Field Detail
-
pluginId
protected final String pluginId
-
-
Constructor Detail
-
BundleUtil
public BundleUtil(String pluginId, String bundleName, ResourceBundle bundle)
Construct an instance of this class by specifying the plugin ID.- Parameters:
pluginId
- the identifier of the plugin for which this utility is being instantiatedbundleName
- the name of the resource bundle; used for problem reporting purposes onlybundle
- the resource bundle
-
-
Method Detail
-
getBundleUtil
public static BundleUtil getBundleUtil(Class<?> clazz)
Return theBundleUtil
for the class. The bundle must be in the same package or a parent package of the class.- Parameters:
clazz
-
-
getString
public String getString(String key)
Get the string identified by the given key and localized to the current locale.- Parameters:
key
- the key in the resource file- Returns:
- the localized String, or
"Missing message: " + key + " in: " + this.bundleName
if the string could not be found in the current locale, or"No message available"
if thekey
is null.
-
keyExists
public boolean keyExists(String key)
Determines if the given key exists in the resource file.- Parameters:
key
- the key in the resource file- Returns:
- True if the key exists.
- Since:
- 4.0
-
getString
public String getString(String key, List parameters)
Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.- Parameters:
key
- the key in the resource fileparameters
- the list of parameters that should replace placeholders in the localized string (e.g., "{0}", "{1}", etc.)- Returns:
- the localized String, or
"Missing message: " + key + " in: " + this.bundleName
if the string could not be found in the current locale, or"No message available"
if thekey
is null.
-
getString
public String getString(String key, Object... parameters)
Get the string identified by the given key and localized to the current locale, and replace placeholders in the localized string with the string form of the parameters.- Parameters:
key
- the key in the resource fileparameters
- the list of parameters that should replace placeholders in the localized string (e.g., "{0}", "{1}", etc.)- Returns:
- the localized String, or
"Missing message: " + key + " in: " + this.bundleName
if the string could not be found in the current locale, or"No message available"
if thekey
is null.
-
gs
public String gs(BundleUtil.Event key, Object... parameters)
-
-