|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.action.SimpleMessage
public class SimpleMessage
A simple non-error message that uses the String supplied to it as the message (i.e. it does not look up the message in a resource bundle).
Messages may contain one or more "replacement parameters". To use replacement parameters a message must contain the replacement token {#} where # is the numeric index of the replacement parameter.
For example, to construct a message with two replacement parameters you might supply a message like:
Welcome back {0}, your last login was on {1,date,short}.
At runtime this might get replaced out to result in a message for the user that looks like "Welcome back Johnnie, your last login was on 01/01/2006".
MessageFormat
is used to merge the parameters in to the message and as
a result the parameters can themselves receive formatting through the various java.text.*
formatters.
MessageFormat
,
Serialized FormConstructor Summary | |
---|---|
protected |
SimpleMessage(Object... parameters)
Helper constructor to allow subclasses to provide and manipulate replacement parameters without having to supply a message String. |
|
SimpleMessage(String message,
Object... parameters)
Constructs a message with the supplied message string and zero or more parameters to be merged into the message. |
Method Summary | |
---|---|
boolean |
equals(Object o)
Checks equality by ensuring that the current instance and the 'other' instance are instances of the same class (though not necessarily SimpleMessage!) and that the message String and replacement parameters provided are the same. |
String |
getMessage()
Returns the exact message that was supplied in the constructor. |
String |
getMessage(Locale locale)
Uses the String message passed in as the message template and combines it with any replacement parameters provided to construct a message for display to the user. |
protected String |
getMessageTemplate(Locale locale)
Simply returns the message passed in at Construction time. |
Object[] |
getReplacementParameters()
Allows subclasses to access the replacement parameters for this message. |
int |
hashCode()
Generated hash code method. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleMessage(String message, Object... parameters)
message
- the String message to display to the user, optionally with placeholders
for replacement parametersparameters
- protected SimpleMessage(Object... parameters)
parameters
- zero or more parameters for replacement into the messageMethod Detail |
---|
public String getMessage(Locale locale)
getMessage
in interface Message
locale
- the locale of the current request
protected String getMessageTemplate(Locale locale)
locale
- the Locale of the message template desired
public String getMessage()
public Object[] getReplacementParameters()
public boolean equals(Object o)
equals
in class Object
o
- another object that is a SimpleMessage or subclass thereof
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |