Package org.openjdk.asmtools.util
Class I18NResourceBundle
java.lang.Object
java.util.ResourceBundle
org.openjdk.asmtools.util.I18NResourceBundle
A class that lazily opens a package-specific resource bundle containing localization
data for a class.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ClassLoader
private ResourceBundle
private String
private boolean
Fields inherited from class java.util.ResourceBundle
parent
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
I18NResourceBundle
(String name, ClassLoader cl) Create a resource bundle for the given name. -
Method Summary
Modifier and TypeMethodDescriptionstatic I18NResourceBundle
Get a package-specific resource bundle for a class containing localization data.getKeys()
A required internal method for ResourceBundle.getName()
Returns the name of this bundle (useful for methods using bundle name instead of instance, such asLogger
creation,getOptionalString
(String key) Get an entry from the bundle, returning null if it is not found.Get an entry from the resource bundle.protected Object
handleGetObject
(String key) A required internal method for ResourceBundle.void
setWarn
(boolean warn) Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
-
Field Details
-
warn
private boolean warn -
name
-
delegate
-
classLoader
-
-
Constructor Details
-
I18NResourceBundle
Create a resource bundle for the given name. The actual resource bundle will not be loaded until it is needed.- Parameters:
name
- The name of the actual resource bundle to use.
-
-
Method Details
-
getBundleForClass
Get a package-specific resource bundle for a class containing localization data. The bundle is named i18n.properties in the same package as the given class.- Parameters:
c
- the class for which to obtain the resource bundle- Returns:
- the appropriate resource bundle for the class
-
getString
Get an entry from the resource bundle. If the resource cannot be found, a message is printed to the console and the result will be a string containing the method parameters.- Parameters:
key
- the name of the entry to be returnedargs
- an array of arguments to be formatted into the result usingMessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
- Returns:
- the formatted string
-
getOptionalString
Get an entry from the bundle, returning null if it is not found.- Parameters:
key
- the name of the entry to be returned- Returns:
- the value of the entry, or null if it is not found.
-
setWarn
public void setWarn(boolean warn) -
handleGetObject
A required internal method for ResourceBundle. Load the actual resource bundle, if it has not yet been loaded, then hand the request off to that bundle. If the resource cannot be found, a message is printed to the console and the result will be the original tag.- Specified by:
handleGetObject
in classResourceBundle
- Throws:
MissingResourceException
-
getKeys
A required internal method for ResourceBundle. Load the actual resource bundle, if it has not yet been loaded, then hand the request off to that bundle.- Specified by:
getKeys
in classResourceBundle
-
getName
Returns the name of this bundle (useful for methods using bundle name instead of instance, such asLogger
creation,- Returns:
- the name of this resource bundle
-