it.amattioli.workstate.exceptions
Class MessageBundle

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.exceptions.MessageBundle
Direct Known Subclasses:
ErrorMessages

public class MessageBundle
extends Object

Abstract class for the rapid development of message bundle retrieving classes.

Messages can contains place-holders for parameter substitution. Place holder syntax is the same as for MessageFormat: "{0}" is the first parameter, "{1}" is the second one and so on.


Constructor Summary
MessageBundle(ResourceBundle messages)
          Construct a MessageBundle using the given ResourceBundle.
MessageBundle(String bundleName)
          Construct a MessageBundle using the ResourceBundle with the given name.
MessageBundle(String bundleName, Locale locale)
          Construct a MessageBundle using the ResourceBundle with the given name and the given Locale.
 
Method Summary
 String getErrorMessage(KeyedMessage message)
           
 String getErrorMessage(String key)
          Return the message with the given key
 String getErrorMessage(String key, String... args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBundle

public MessageBundle(ResourceBundle messages)
Construct a MessageBundle using the given ResourceBundle.

Parameters:
messages - the ResourceBundle used to retrieve messages.

MessageBundle

public MessageBundle(String bundleName)
Construct a MessageBundle using the ResourceBundle with the given name.

Parameters:
bundleName - the full qualified name of the ResourceBundle

MessageBundle

public MessageBundle(String bundleName,
                     Locale locale)
Construct a MessageBundle using the ResourceBundle with the given name and the given Locale.

Parameters:
bundleName - the full qualified name of the ResourceBundle
locale - the locale for the messages
Method Detail

getErrorMessage

public String getErrorMessage(String key)
Return the message with the given key

Parameters:
key - the message key
Returns:
the message with the given key
Throws:
MissingResourceException - if there is no resource in the bundle with the given key

getErrorMessage

public String getErrorMessage(String key,
                              String... args)

getErrorMessage

public String getErrorMessage(KeyedMessage message)


Copyright © 2011. All Rights Reserved.