|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.faktorips.runtime.Message
public class Message
A human readable text message with an optional code that identifies the type of the message and a severity that indicates if this is an error, warning or information.
In addition a message provides access to the objects and their properties the message relates to. E.g. if a message reads that "insured person's age must be at least 18" than the person's age is invalid. This information can be used for example to mark controls in the UI that display this property.
If the provided message has replacement parameters that cannot be evaluated while creating the
message text, it is possible to provide there parameters to the message object. Have a look at
MsgReplacementParameter for further information.
If you need any further information stored with the message, it is possible to implement the IMarker object and provide some additional markers to the message. The exact use of the markers depends on the custom implementation.
Message is an immutable value object. Two message objects are considered equal if they have the same severity, code, text, "invalid properties" and replacement parameters.
MsgReplacementParameter,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
Message.Builder
A builder for the Message class. |
| Field Summary | |
|---|---|
static Severity |
ERROR
Severity error. |
static Severity |
INFO
Severity info. |
static Severity |
NONE
Severity none. |
static Severity |
WARNING
Severity warning. |
| Constructor Summary | |
|---|---|
Message(Message.Builder builder)
Creates a new message by using the fields of a Message.Builder. |
|
Message(Message msg)
Creates a new message by copying everything of the given Message. |
|
Message(String text,
Severity severity)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties,
List<MsgReplacementParameter> replacementParameters)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties,
List<MsgReplacementParameter> parameters,
Set<? extends IMarker> markers)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
Object invalidObject)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
ObjectProperty[] invalidObjectProperties)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
ObjectProperty[] invalidObjectProperties,
MsgReplacementParameter[] parameters)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty,
List<MsgReplacementParameter> parameters)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty,
MsgReplacementParameter... parameters)
Creates a new message by defining the following parameters. |
|
Message(String code,
String text,
Severity severity,
Object invalidObject,
String... invalidObjectProperties)
Creates a new message by defining the following parameters. |
|
| Method Summary | |
|---|---|
static Message |
createCopy(Message msg,
Object oldObject,
Object newObject)
Creates a copy from the message and replaces all references to the old object with the new object. |
boolean |
equals(Object o)
Returns true if o is a Message and severity, code and text are equal. |
static Message.Builder |
error(String text)
Creates a new Message.Builder with ERROR and the given message. |
String |
getCode()
Returns the message code. |
List<ObjectProperty> |
getInvalidObjectProperties()
Returns the list of object properties the message refers to. |
Set<? extends IMarker> |
getMarkers()
Returns a set of IMarkers associated with this class. |
int |
getNumOfInvalidObjectProperties()
Returns the number of referenced invalid object properties. |
int |
getNumOfReplacementParameters()
Returns the number of replacement parameters.. |
List<MsgReplacementParameter> |
getReplacementParameters()
Returns the list of replacement parameters. |
Object |
getReplacementValue(String paramName)
Returns the value for the given replacement parameter. |
Severity |
getSeverity()
Returns the message's severity as one of the constants ERROR, WARNING, INFO or NONE. |
String |
getText()
Returns the humand readable message text. |
int |
hashCode()
|
boolean |
hasMarker(IMarker marker)
Returns true if the message contains the specified IMarker marker
otherwise false. |
boolean |
hasMarkers()
Returns true if the message has markers otherwise false. |
boolean |
hasReplacementParameter(String paramName)
Returns true if the message has a replacement parameter with the given name,
otherwise false. |
static Message.Builder |
info(String text)
Creates a new Message.Builder with INFO and the given message. |
static Message |
newError(String code,
String text)
Constructs a new error message. |
static Message |
newInfo(String code,
String text)
Constructs a new information message. |
static Message |
newWarning(String code,
String text)
Constructs a new warning message. |
String |
toString()
|
static Message.Builder |
warning(String text)
Creates a new Message.Builder with WARNING and the given message. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Severity NONE
public static final Severity INFO
public static final Severity WARNING
public static final Severity ERROR
| Constructor Detail |
|---|
public Message(Message.Builder builder)
Message.Builder.
builder - the Message.Builderpublic Message(Message msg)
Message.
msg - the Message to copy from
public Message(String text,
Severity severity)
text - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFO
public Message(String code,
String text,
Severity severity)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFO
public Message(String code,
String text,
Severity severity,
Object invalidObject)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObject - An object properties the message refers to
public Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperty - An object property the message refers to
public Message(String code,
String text,
Severity severity,
Object invalidObject,
String... invalidObjectProperties)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFO:
ERROR, WARNING or INFOinvalidObject - the Object of the ObjectPropertyinvalidObjectProperties - An array of propertie's names the message refers to
public Message(String code,
String text,
Severity severity,
ObjectProperty[] invalidObjectProperties)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperties - An array of object properties the message refers to
public Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperties - A list of object properties the message refers to
public Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties,
List<MsgReplacementParameter> replacementParameters)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperties - A list of object properties the message refers to
public Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty,
MsgReplacementParameter... parameters)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperty - A list of object properties the message refers toparameters - an array of replacement parameters
public Message(String code,
String text,
Severity severity,
ObjectProperty invalidObjectProperty,
List<MsgReplacementParameter> parameters)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperty - An object properties the message refers toparameters - a list of replacement parameters
public Message(String code,
String text,
Severity severity,
ObjectProperty[] invalidObjectProperties,
MsgReplacementParameter[] parameters)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperties - An array of object properties the message refers toparameters - an array of replacement parameters
public Message(String code,
String text,
Severity severity,
List<ObjectProperty> invalidObjectProperties,
List<MsgReplacementParameter> parameters,
Set<? extends IMarker> markers)
code - A message code that identifies the kind of the messagetext - The human readable text of this messageseverity - The message's severity: ERROR, WARNING or INFOinvalidObjectProperties - A list of object properties the message refers toparameters - a list of replacement parametersmarkers - a list of markers. If this parameter is null an empty list is set as markers.
The List of markers is| Method Detail |
|---|
public static final Message.Builder error(String text)
Message.Builder with ERROR and the given message.
To create a new Message you can use for example:
Message.error("MessageText").code("1").invalidObjects("object",
"property").create();
text - The human readable text of this messagepublic static final Message.Builder warning(String text)
Message.Builder with WARNING and the given message.
To create a new Message you can use for example:
Message.warning("MessageText").code("1").invalidObjects("object",
"property").create();
text - The human readable text of this messagepublic static final Message.Builder info(String text)
Message.Builder with INFO and the given message.
To create a new Message you can use for example:
Message.info("MessageText").code("1").invalidObjects("object",
"property").create();
text - The human readable text of this message
public static final Message createCopy(Message msg,
Object oldObject,
Object newObject)
public static final Message newInfo(String code,
String text)
public static final Message newWarning(String code,
String text)
public static final Message newError(String code,
String text)
public Severity getSeverity()
public String getText()
public String getCode()
public int getNumOfInvalidObjectProperties()
public List<ObjectProperty> getInvalidObjectProperties()
public int getNumOfReplacementParameters()
public List<MsgReplacementParameter> getReplacementParameters()
public boolean hasReplacementParameter(String paramName)
true if the message has a replacement parameter with the given name,
otherwise false. Returns false if paramName is null.
public Object getReplacementValue(String paramName)
null if the
message hasn't got a parameter with the indicated name.
hasReplacementParameter(String)public Set<? extends IMarker> getMarkers()
IMarkers associated with this class. Returns an empty set if no
markers are set.
public boolean hasMarker(IMarker marker)
true if the message contains the specified IMarker marker
otherwise false.
public boolean hasMarkers()
true if the message has markers otherwise false.
public String toString()
toString in class Objectpublic boolean equals(Object o)
equals in class ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||