org.iscreen.impl
Class DefaultValidatorContext

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

public class DefaultValidatorContext
extends java.lang.Object
implements InternalValidatorContext

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

Author:
Shellman, Dan

Field Summary
protected  ContextBean contextBean
           
protected  java.util.List failures
           
protected  java.util.Locale locale
           
protected  ValidationService service
           
protected  ValidationTrace trace
           
protected  ValidatorWrapper validator
           
 
Constructor Summary
DefaultValidatorContext(ValidationService theService, ContextBean theRoot, java.util.Locale theLocale)
          Default constructor.
 
Method Summary
 void addRawFailures(java.util.List failureList, ValidationService service)
          Adds "raw" failures (which is a List of ValidationFailure objects) to the existing set of failures.
 int getCount()
          Calculates the failure counts.
 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.
 ValidationService getValidationService()
          Retrieves the validation service this context is being used with.
 java.lang.String getValidatorName()
          Used to obtain the name of the validator that is currently being used.
This is handy for tracing/logging.
 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 setValidationTrace(ValidationTrace theTrace)
          Sets the trace so that the context can use it for reporting failures.
 void setValidator(ValidatorWrapper wrapper)
          Sets the ValidatorWrapper that the context needs to use.
 
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

contextBean

protected ContextBean contextBean

locale

protected java.util.Locale locale

validator

protected ValidatorWrapper validator

service

protected ValidationService service

trace

protected ValidationTrace trace
Constructor Detail

DefaultValidatorContext

public DefaultValidatorContext(ValidationService theService,
                               ContextBean 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.

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.

getValidationService

public ValidationService getValidationService()
Description copied from interface: ValidatorContext
Retrieves the validation service this context is being used with.

Specified by:
getValidationService in interface ValidatorContext
Returns:
Returns the validation service (validation set) that is being used.

getFailures

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

Specified by:
getFailures in interface InternalValidatorContext
Returns:
Returns a List of current failures.

addRawFailures

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

Specified by:
addRawFailures in interface InternalValidatorContext
Parameters:
failureList - The List of ValidationFailures to add to this context.
service - The validation service representing the failures.

getCount

public int getCount()
Calculates the failure counts.

Specified by:
getCount in interface InternalValidatorContext
Returns:
Returns the total failure count.

setValidator

public void setValidator(ValidatorWrapper wrapper)
Sets the ValidatorWrapper that the context needs to use.

Specified by:
setValidator in interface InternalValidatorContext
Parameters:
wrapper - The ValidatorWrapper to use.

setValidationTrace

public void setValidationTrace(ValidationTrace theTrace)
Description copied from interface: InternalValidatorContext
Sets the trace so that the context can use it for reporting failures.

Specified by:
setValidationTrace in interface InternalValidatorContext
Parameters:
theTrace - The ValidationTrace instace.

getValidatorName

public java.lang.String getValidatorName()
Used to obtain the name of the validator that is currently being used.
This is handy for tracing/logging.

Specified by:
getValidatorName in interface ValidatorContext
Returns:
The name of the validator