de.mguennewig.pobjform
Class Message

java.lang.Object
  extended by de.mguennewig.pobjform.Message

public final class Message
extends java.lang.Object

An encapsulation of an individual message returned by the PObjForm.validate() method of an form, consisting of a message key (to be used to look up message text in an appropriate message resources database) plus placeholder objects that can be used for parametric replacement in the message text.

The placeholder objects are referenced in the message text using the same syntax used by the JDK MessageFormat class. Thus, the first placeholder is '{0}', the second is '{1}', etc.

Author:
Michael Günnewig

Constructor Summary
Message(java.lang.String key, java.lang.Object... values)
          Construct a message with the specified replacement values.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 java.lang.String format(java.util.ResourceBundle bundle)
          Formats this message into a localized text ready to present to the user.
 java.lang.String getKey()
          Get the message key for this message.
 java.lang.Object[] getValues()
          Get the replacement values for this message.
 int hashCode()
          
static Message parse(java.lang.String s)
          Construct a Message from its textual representation.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Message

public Message(java.lang.String key,
               java.lang.Object... values)
Construct a message with the specified replacement values.

Method Detail

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

format

public java.lang.String format(java.util.ResourceBundle bundle)
Formats this message into a localized text ready to present to the user.

Throws:
java.util.MissingResourceException - if the resource for the key can not be found.

getKey

public java.lang.String getKey()
Get the message key for this message.


getValues

public java.lang.Object[] getValues()
Get the replacement values for this message.


hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

parse

public static Message parse(java.lang.String s)
Construct a Message from its textual representation.

The string must follow the schema:

<key> (<argumentStringLength>:<argumentString>)*

Throws:
java.lang.NumberFormatException - if the string contains an argumentStringLength that is not a valid number.
See Also:
toString()