com.planetalia.dynject.validation
Class ErrorMessage

java.lang.Object
  extended by com.planetalia.dynject.validation.ErrorMessage

public class ErrorMessage
extends java.lang.Object

Represents a single error message notifying of an error condition during the validation/assignment process

Author:
Alexander Hristov

Constructor Summary
ErrorMessage()
          Creates an empty error message
ErrorMessage(java.lang.String messageKey)
          Creates an error message with the specified message key
ErrorMessage(java.lang.String messageKey, java.lang.Object... params)
          Creates an error message with the specified message key and message parameters
ErrorMessage(java.lang.String code, java.lang.String messageKey)
          Creates an error message with a specified error code and a message key referencing some external message
 
Method Summary
 java.lang.String getCode()
          Returns the error code
 java.lang.Object getData()
          Returns the data item that caused the error
 java.lang.Object getInstance()
          Returns the instance that this message is associated to.
 java.lang.String getMessage()
          Returns the text of the message, for literal messages
 java.lang.String getMessageKey()
          Returns the message key, for messages located in resource bundles
 java.lang.Object[] getMessageParams()
          Retrieves the message parameters, used for formatting
 java.lang.String getPropertyName()
          Returns the name of the property that created this error message
 java.lang.Class<? extends java.lang.annotation.Annotation> getTriggeringAnnotation()
          Returns the validating annotation that triggered this error
 void setCode(java.lang.String code)
          Sets this message's error code
 void setData(java.lang.Object data)
          Sets the data item that caused the error
 void setInstance(java.lang.Object instance)
          Sets the instance that this message is associated to.
 void setMessage(java.lang.String message)
          Sets the literal text of this message
 void setMessageKey(java.lang.String messageKey)
          Sets this message's key, for messages located in resource bundles
 void setMessageParams(java.lang.Object... messageParams)
          Sets this message's parameters
 void setPropertyName(java.lang.String propertyName)
          Sets the Name of the property that created this error message
 void setTriggeringAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> triggeringAnnotation)
          Sets the validating annotation that triggered this error
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ErrorMessage

public ErrorMessage()
Creates an empty error message


ErrorMessage

public ErrorMessage(java.lang.String code,
                    java.lang.String messageKey)
Creates an error message with a specified error code and a message key referencing some external message

Parameters:
code - Error code
messageKey - Message key

ErrorMessage

public ErrorMessage(java.lang.String messageKey)
Creates an error message with the specified message key

Parameters:
messageKey - Message key

ErrorMessage

public ErrorMessage(java.lang.String messageKey,
                    java.lang.Object... params)
Creates an error message with the specified message key and message parameters

Parameters:
messageKey - Message key
params - Message parameters
Method Detail

getCode

public java.lang.String getCode()
Returns the error code

Returns:
Error Code

setCode

public void setCode(java.lang.String code)
Sets this message's error code

Parameters:
code - New error code

getMessage

public java.lang.String getMessage()
Returns the text of the message, for literal messages

Returns:
Literal message text

setMessage

public void setMessage(java.lang.String message)
Sets the literal text of this message

Parameters:
message - New literal message text

getMessageKey

public java.lang.String getMessageKey()
Returns the message key, for messages located in resource bundles

Returns:
Message key

setMessageKey

public void setMessageKey(java.lang.String messageKey)
Sets this message's key, for messages located in resource bundles

Parameters:
messageKey - new key

getMessageParams

public java.lang.Object[] getMessageParams()
Retrieves the message parameters, used for formatting

Returns:
Message parameters

setMessageParams

public void setMessageParams(java.lang.Object... messageParams)
Sets this message's parameters

Parameters:
messageParams - Message parameters

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getData

public java.lang.Object getData()
Returns the data item that caused the error

Returns:
Data item that caused the error. May be null, both if uknown or not applicable OR because the data item itself was null

setData

public void setData(java.lang.Object data)
Sets the data item that caused the error

Parameters:
data - Data item that caused the error

getInstance

public java.lang.Object getInstance()
Returns the instance that this message is associated to.

Returns:
Instance that this message is associated to.

setInstance

public void setInstance(java.lang.Object instance)
Sets the instance that this message is associated to.

Parameters:
instance - Instance that this message is associated to.

getPropertyName

public java.lang.String getPropertyName()
Returns the name of the property that created this error message

Returns:
Name of the property that created this error message

setPropertyName

public void setPropertyName(java.lang.String propertyName)
Sets the Name of the property that created this error message

Parameters:
propertyName - Name of the property that created this error message

getTriggeringAnnotation

public java.lang.Class<? extends java.lang.annotation.Annotation> getTriggeringAnnotation()
Returns the validating annotation that triggered this error

Returns:
Validating annotation that triggered this error

setTriggeringAnnotation

public void setTriggeringAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> triggeringAnnotation)
Sets the validating annotation that triggered this error

Parameters:
triggeringAnnotation - Validating annotation that triggered this error