org.javalid.core
Class ValidationMessage

java.lang.Object
  extended by org.javalid.core.ValidationMessage
All Implemented Interfaces:
java.io.Serializable

public class ValidationMessage
extends java.lang.Object
implements java.io.Serializable

This class defines a general ValidationMessage that is used by the validator to store a validation error into.

Since:
1.0
Version:
1.1
Author:
M.Reuvers
See Also:
Serialized Form

Constructor Summary
ValidationMessage(java.lang.String path, java.lang.String message, java.lang.Object[] values, boolean globalMessage)
          Constructs a validation message.
 
Method Summary
 java.lang.String getMessage()
          Returns the message code, you can override error codes in your own property file.
 java.lang.String getPath()
          Returns the error path
 java.lang.Object[] getValues()
          Returns the values associated to this message (if any), see the validation annotations to find out what is stored in here exactly.
 boolean isGlobalMessage()
          Returns true if this message should be a global message (note that this property is originally taken from annotation's globalMessage), there it can be used to say that an error when validating for that annotation must be shown as a global message instead of using the validation path.
 void setGlobalMessage(boolean globalMessage)
          Set to true if this message represents a global message (validation path is ignored)
 void setMessage(java.lang.String message)
          Set the message code for this message
 void setPath(java.lang.String path)
          Set the validation path for this message
 void setValues(java.lang.Object[] values)
          The value parameters for this message
 java.lang.String toString()
          Returns string representation of content of this message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValidationMessage

public ValidationMessage(java.lang.String path,
                         java.lang.String message,
                         java.lang.Object[] values,
                         boolean globalMessage)
Constructs a validation message.

Parameters:
path - The full error path to the method where something went wrong, e.g. A { public String getExample() { .. } } if with error, would result in: example
message - The message code (e.g. jv_error_XXXX)
values - Values if relevant for the specific validation / message code), see the specific annotations to find out what is stored in the values instance.
Method Detail

getPath

public java.lang.String getPath()
Returns the error path

Returns:
The error path to the method that was not valid

getMessage

public java.lang.String getMessage()
Returns the message code, you can override error codes in your own property file.

Returns:
The message code

getValues

public java.lang.Object[] getValues()
Returns the values associated to this message (if any), see the validation annotations to find out what is stored in here exactly.

Returns:
Values associated to this message

isGlobalMessage

public boolean isGlobalMessage()
Returns true if this message should be a global message (note that this property is originally taken from annotation's globalMessage), there it can be used to say that an error when validating for that annotation must be shown as a global message instead of using the validation path. This method is a hint for the message converters, what to do with it (when its true they will add it as global message irrelevant of validationpath).

Returns:
True if so, false otherwise.

toString

public java.lang.String toString()
Returns string representation of content of this message

Overrides:
toString in class java.lang.Object
Returns:
Returns string representation of content of this message

setPath

public void setPath(java.lang.String path)
Set the validation path for this message

Parameters:
path - The path for this message
Since:
1.1

setMessage

public void setMessage(java.lang.String message)
Set the message code for this message

Parameters:
message - The new message code (from properties file)
Since:
1.1

setValues

public void setValues(java.lang.Object[] values)
The value parameters for this message

Parameters:
values - The parameters

setGlobalMessage

public void setGlobalMessage(boolean globalMessage)
Set to true if this message represents a global message (validation path is ignored)

Parameters:
globalMessage - If this message is a global message or not