org.iscreen.impl
Class DefaultValidatorContext

java.lang.Object
  extended by org.iscreen.impl.DefaultValidatorContext
All Implemented Interfaces:
ValidatorContext

public class DefaultValidatorContext
extends java.lang.Object
implements ValidatorContext

This is the default implementation of the ValidatorContext that's passed to Validators during validation.

Author:
Shellman, Dan

Field Summary
protected  java.util.List failures
           
protected  java.util.Locale locale
           
protected  OgnlRoot root
           
protected  java.util.List warnings
           
 
Constructor Summary
DefaultValidatorContext(OgnlRoot theRoot, java.util.Locale theLocale)
          Default constructor.
 
Method Summary
 void addRawFailures(java.util.List failureList)
          Adds "raw" failures (which is a List of ValidationFailure objects) to the existing set of failures.
 void addRawWarnings(java.util.List warningList)
          Adds "raw" warnings (which is a List of ValidationFailure objects) to the existing set of warnings.
 int getCount()
          Calculates the total failure and warning counts.
 int getFailureCount()
          Retrieves the number of current failures in this context.
 java.util.List getFailures()
          Retrieves a List of the current failures within this context.
 java.util.Locale getLocale()
          Gets the current locale being used for this validation.
 int getWarningCount()
          Retrieves the number of current warnings in this context.
 java.util.List getWarnings()
          Retrieves a List of the current warnings within this context.
 void reportFailure(FailureMessage messageObject)
          Called to report a validation failure.
 void reportFailure(FailureMessage messageObject, java.lang.Object failureObject)
          Called to report a validation failure.
 void reportWarning(FailureMessage messageObject)
          Called to report a validation warning.
 void reportWarning(FailureMessage messageObject, java.lang.Object failureObject)
          Called to report a validation warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

failures

protected java.util.List failures

warnings

protected java.util.List warnings

root

protected OgnlRoot root

locale

protected java.util.Locale locale
Constructor Detail

DefaultValidatorContext

public DefaultValidatorContext(OgnlRoot theRoot,
                               java.util.Locale theLocale)
Default constructor.

Method Detail

reportFailure

public void reportFailure(FailureMessage messageObject)
Description copied from interface: ValidatorContext
Called to report a validation failure. The Object provided is the failure message (usually configured as a setter on the individual Validator).

Specified by:
reportFailure in interface ValidatorContext
Parameters:
messageObject - The message failure object representing the failure.

reportFailure

public void reportFailure(FailureMessage messageObject,
                          java.lang.Object failureObject)
Description copied from interface: ValidatorContext
Called to report a validation failure. The Object provided is the failure message (usually configured as a setter on the individual Validator). The additional failure object is used to help generate the actual failure message (it becomes accessible to the message via the OGNL root).

Specified by:
reportFailure in interface ValidatorContext
Parameters:
messageObject - The message failure object representing the failure.
failureObject - A Validator-specific failure object to be made accessible to the message via the OGNL root.

reportWarning

public void reportWarning(FailureMessage messageObject)
Description copied from interface: ValidatorContext
Called to report a validation warning. The Object provided is the failure message (usually configured as a setter on the individual Validator). A warning is handled as a separate exception that allows the user of this API to differentiate between validation failures and warnings.

Specified by:
reportWarning in interface ValidatorContext
Parameters:
messageObject - The message failure object representing the warning.

reportWarning

public void reportWarning(FailureMessage messageObject,
                          java.lang.Object failureObject)
Description copied from interface: ValidatorContext
Called to report a validation warning. The Object provided is the failure message (usually configured as a setter on the individual Validator). The additional failure object is used to help generate the actual failure message (it becomes accessible to the message via the OGNL root). A warning is handled as a separate exception that allows the user of this API to differentiate between validation failures and warnings.

Specified by:
reportWarning in interface ValidatorContext
Parameters:
messageObject - The message failure object representing the warning.
failureObject - A Validator-specific failure object to be made accessible to the message via the OGNL root.

getLocale

public java.util.Locale getLocale()
Description copied from interface: ValidatorContext
Gets the current locale being used for this validation.

Specified by:
getLocale in interface ValidatorContext
Returns:
Returns the current locale being used.

getFailures

public java.util.List getFailures()
Retrieves a List of the current failures within this context. This List contains ValidationFailure objects.

Returns:
Returns a List of current failures.

getWarnings

public java.util.List getWarnings()
Retrieves a List of the current warnings within this context. This List contains ValidationFailure objects.

Returns:
Returns a List of current warnings.

addRawFailures

public void addRawFailures(java.util.List failureList)
Adds "raw" failures (which is a List of ValidationFailure objects) to the existing set of failures.

Parameters:
failureList - The List of ValidationFailures to add to this context.

addRawWarnings

public void addRawWarnings(java.util.List warningList)
Adds "raw" warnings (which is a List of ValidationFailure objects) to the existing set of warnings.

Parameters:
warningList - The List of ValidationFailures to add to this context.

getFailureCount

public int getFailureCount()
Retrieves the number of current failures in this context.

Returns:
Returns the number of failures.

getWarningCount

public int getWarningCount()
Retrieves the number of current warnings in this context.

Returns:
Returns the number of warnings.

getCount

public int getCount()
Calculates the total failure and warning counts. Basically, returns the addition of getFailureCount() and getWarningCount() calls.

Returns:
Returns the total failure and warning counts.