Class Messages
ResourceBundle.
 Wraps a ResourceBundle to provide some useful additional functionality.
- 
      Instead of throwing MissingResourceException, theResourceBundle.getString(String)method will return"{!key}" if the message could not be found.
- Supported hierarchical lookup of resources from parent parent classes.
- Support for easy retrieval of localized bundles.
- Support for generalized resource bundles (e.g. properties files containing keys for several classes).
The following example shows the basic usage of this class for retrieving localized messages:
   
   
   The ability to resolve keys prefixed by class name allows you to place all your messages in a single file such
   as a common 
The following shows how to retrieve messages from a common bundle:
   
Resource bundles are searched using the following base name patterns:
- "{package}.{name}" 
- "{package}.i18n.{name}" 
- "{package}.nls.{name}" 
- "{package}.messages.{name}" 
   These patterns can be customized using the Messages.Builder.baseNames(String...) method.
 
Localized messages can be retrieved in the following way:
   
See Also:
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class java.util.ResourceBundleResourceBundle.Control
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleancontainsKey(String key) static final Messages.BuilderStatic creator.findFirstString(String... keys) Looks for all the specified keys in the resource bundle and returns the first value that exists.Returns this message bundle for the specified locale.getKeys()Similar toResourceBundle.getString(String)except allows you to pass inMessageFormatobjects.protected ObjecthandleGetObject(String key) keySet()Returns all keys in this resource bundle with the specified prefix.static final MessagesConstructor.static final MessagesConstructor.toString()Methods inherited from class java.util.ResourceBundleclearCache, clearCache, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, setParent
- 
Constructor Details- 
MessagesConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
createStatic creator.- Parameters:
- forClass- The class we're creating this object for.
- Returns:
- A new builder.
 
- 
ofConstructor.- Parameters:
- forClass- The class we're creating this object for.
- Returns:
- A new message bundle belonging to the class.
 
- 
ofConstructor.- Parameters:
- forClass- The class we're creating this object for.
- name- The bundle name (e.g.- "Messages" ).
 If- null , uses the class name.
- Returns:
- A new message bundle belonging to the class.
 
- 
forLocaleReturns this message bundle for the specified locale.- Parameters:
- locale- The locale to get the messages for.
- Returns:
- A new Messagesobject. Nevernull .
 
- 
keySetReturns all keys in this resource bundle with the specified prefix.Keys are returned in alphabetical order. - Parameters:
- prefix- The prefix.
- Returns:
- The set of all keys in the resource bundle with the prefix.
 
- 
getStringSimilar toResourceBundle.getString(String)except allows you to pass inMessageFormatobjects.- Parameters:
- key- The resource bundle key.
- args- Optional- MessageFormat-style arguments.
- Returns:
- The resolved value.  Never null ."{!key}" if the key is missing.
 
- 
findFirstStringLooks for all the specified keys in the resource bundle and returns the first value that exists.- Parameters:
- keys- The list of possible keys.
- Returns:
- The resolved value, or null if no value is found or the resource bundle is missing.
 
- 
handleGetObject- Specified by:
- handleGetObjectin class- ResourceBundle
 
- 
containsKey- Overrides:
- containsKeyin class- ResourceBundle
 
- 
keySet- Overrides:
- keySetin class- ResourceBundle
 
- 
getKeys- Specified by:
- getKeysin class- ResourceBundle
 
- 
toString
 
-