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 interfaceBundleUtil.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 BundleUtilgetBundleUtil(Class<?> clazz)Return theBundleUtilfor the class.StringgetString(String key)Get the string identified by the given key and localized to the current locale.StringgetString(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.StringgetString(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.StringgetStringOrKey(String key)Stringgs(String key, Object... parameters)Stringgs(BundleUtil.Event key, Object... parameters)booleankeyExists(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 theBundleUtilfor 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.bundleNameif the string could not be found in the current locale, or"No message available"if thekeyis 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.bundleNameif the string could not be found in the current locale, or"No message available"if thekeyis 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.bundleNameif the string could not be found in the current locale, or"No message available"if thekeyis null.
-
gs
public String gs(BundleUtil.Event key, Object... parameters)
-
-