org.iscreen
Interface ValidationFailure

All Known Implementing Classes:
ValidationFailureImpl

public interface ValidationFailure

A validation failure represents a single failure reported by a Validator (Validators can report multiple failures, each represented by a separate instance of this class). Each failure has a message (usually designed to be accessible to the end user), a label (usually used to associate the failure with an UI component, though a label is not required), and the Collection of fields (these are really the OGNL expressions used to 'get' properties from the JavaBean being validated) from the JavaBean that was originally validated (normally, there's just one field).

Interface code (such as a web framework) can use instances of this class to display the validation failures. There should be sufficient information associated with each failure to apply the message to the correct location within the interface.

Author:
Shellman, Dan

Field Summary
static int CRITICAL
          Severity level of critical.
static int FAILURE
          Severity level of failure.
static int WARNING
          Severity level of warning.
 
Method Summary
 java.lang.Object getFailureBean()
          Obtains a reference to the bean that failed validation.
 java.util.Collection getFields()
          Retrieves the fields (the OGNL/MVEL expression used to 'get' the properties from the JavaBean being validated) of the JavaBean being validated.
 java.lang.Integer getIndex()
          Retrieves the index of the JavaBean/Object being validated that was an element within an array/Collection of a 'parent' JavaBean being validated (i.e.
 java.lang.String getLabel()
          Retrieves the label associated with this failure.
 java.lang.String getMessage()
          Retrieves the failure message (which has already been evaluated and localized).
 java.lang.String getMessage(java.lang.String messageName)
          Retrieves the failure message based upon the message name.
 java.lang.String getName()
          Retrieves the name of the validator reporting the failure message.
 int getSeverity()
          Retrieves the severity of the failure (i.e.
 ValidationTrace getTrace()
          Retrieves the trace of the failure.
 

Field Detail

WARNING

static final int WARNING
Severity level of warning. Value is 3.

See Also:
Constant Field Values

FAILURE

static final int FAILURE
Severity level of failure. This is the standard/default severity level. Value is 5.

See Also:
Constant Field Values

CRITICAL

static final int CRITICAL
Severity level of critical. Value is 10.

See Also:
Constant Field Values
Method Detail

getLabel

java.lang.String getLabel()
Retrieves the label associated with this failure.

Returns:
Returns the label associated with this failure.

getName

java.lang.String getName()
Retrieves the name of the validator reporting the failure message.

Returns:
Returns the name of the validator.

getMessage

java.lang.String getMessage()
Retrieves the failure message (which has already been evaluated and localized). Calling this method is the same as calling the getMessage( null ) method.

Returns:
Returns the failure message.

getMessage

java.lang.String getMessage(java.lang.String messageName)
Retrieves the failure message based upon the message name. Calling this method with a null name is the same as calling the getMessage() method. This method provides access to different messages related to the failure.

Parameters:
messageName - The 'name' of the message (defined in the configuration.
Returns:
Returns the message for the given name.

getSeverity

int getSeverity()
Retrieves the severity of the failure (i.e. warning, critical, etc.). The greater the number, the higher the severity. See the WARNING, FAILURE, and CRITICAL constants.

Returns:
Returns the severity of the failure.

getFields

java.util.Collection getFields()
Retrieves the fields (the OGNL/MVEL expression used to 'get' the properties from the JavaBean being validated) of the JavaBean being validated.

Returns:
Returns the fields of the JavaBean being validated.

getIndex

java.lang.Integer getIndex()
Retrieves the index of the JavaBean/Object being validated that was an element within an array/Collection of a 'parent' JavaBean being validated (i.e. an object was being validated, and it had a property that was an array/Collection that was 'forwarded' on to another validation set and iterated over. The subsequent members of that array/Collection would have an index of which was being validated at a particular time. This is that index.). If no indexed property was being validated, then this will return null. Note that a null value is different than a zero value, as a zero value represents the first element in an array/Collection, where a null value implies that the JavaBean/Object wasn't involved in an array/Collection in the first place.

Returns:
Returns the index of the JavaBean/Object that was being validated.

getTrace

ValidationTrace getTrace()
Retrieves the trace of the failure. The trace can be used to uniquely know the route taken to reach the failure.

Returns:
Returns the trace of the failure.

getFailureBean

java.lang.Object getFailureBean()
Obtains a reference to the bean that failed validation.

Returns:
Returns a reference to the bean