org.iscreen.impl
Class ValidationServiceValidator

java.lang.Object
  extended by org.iscreen.impl.ValidationServiceValidator
All Implemented Interfaces:
ValidatorWrapper
Direct Known Subclasses:
MvelValidationServiceValidator, OgnlValidationServiceValidator

public abstract class ValidationServiceValidator
extends java.lang.Object
implements ValidatorWrapper

This is a special ValidatorWrapper that forwards validation to a different Validation Set.

Author:
Shellman, Dan

Field Summary
protected  boolean failFastFlag
           
protected  java.lang.String ifExp
           
protected  java.lang.String iterateExp
           
protected  java.lang.String mapExp
           
protected  java.lang.String name
           
protected  ValidationService parentService
           
protected  DefaultValidationService wrappedService
           
 
Constructor Summary
ValidationServiceValidator(DefaultValidationService service, ValidationService theParentService)
          Default constructor.
 
Method Summary
protected  InternalValidatorContext createNewContext(ContextBean newContextBean, java.util.Locale newLocale, InternalValidatorContext oldContext)
          Constructs a new context for the validation set being called.
 DocumentationIterator getDoc()
          Called to retrieve the documentation for the validator.
 java.lang.String getIfExpression()
           
 java.lang.String getIterateExpression()
           
 java.lang.String getMapExpression()
           
 java.lang.String getName()
          Called to retrieve the "name" of the validator.
 boolean isFailFast()
           
protected abstract  java.lang.Object mapObject(InternalValidatorContext context, ContextBean contextBean, java.lang.Object obj)
          Handle the mapping of the object being validated to the property that will be validated (may be the object, itself).
 void setFailFast(boolean flag)
           
 void setIfExpression(java.lang.String exp)
           
 void setIterateExpression(java.lang.String exp)
           
 void setMapExpression(java.lang.String exp)
           
 void setName(java.lang.String theName)
           
protected abstract  boolean shouldExecute(InternalValidatorContext context, ContextBean contextBean, java.lang.Object obj)
          Determines whether the inclusion/call to the validation set should occur.
protected abstract  boolean shouldIterate(InternalValidatorContext context, ContextBean contextBean, java.lang.Object obj)
          Determines whether we're iterating over the mapped object.
 boolean validate(InternalValidatorContext context, ContextBean contextBean, ValidationTrace trace, java.lang.Object obj)
          Called to have the wrapper validate the passed object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wrappedService

protected DefaultValidationService wrappedService

parentService

protected ValidationService parentService

ifExp

protected java.lang.String ifExp

iterateExp

protected java.lang.String iterateExp

mapExp

protected java.lang.String mapExp

failFastFlag

protected boolean failFastFlag

name

protected java.lang.String name
Constructor Detail

ValidationServiceValidator

public ValidationServiceValidator(DefaultValidationService service,
                                  ValidationService theParentService)
Default constructor.

Parameters:
service - The validation service this validator represents
theParentService - The parent validation service
Method Detail

validate

public boolean validate(InternalValidatorContext context,
                        ContextBean contextBean,
                        ValidationTrace trace,
                        java.lang.Object obj)
Description copied from interface: ValidatorWrapper
Called to have the wrapper validate the passed object. It is expected that the wrapper will update the root object as appropriate. The context already has access to the root that is being passed in.

Specified by:
validate in interface ValidatorWrapper
Parameters:
context - The validation context to pass on to the contained validator.
contextBean - The OGNL root, to be updated as appropriate.
trace - The validation trace to track what calls what.
obj - The object to be validated.
Returns:
Returns true if validation should continue; false if it should be halted.

setIfExpression

public void setIfExpression(java.lang.String exp)

getIfExpression

public java.lang.String getIfExpression()

setIterateExpression

public void setIterateExpression(java.lang.String exp)

getIterateExpression

public java.lang.String getIterateExpression()

setMapExpression

public void setMapExpression(java.lang.String exp)

getMapExpression

public java.lang.String getMapExpression()

setFailFast

public void setFailFast(boolean flag)

isFailFast

public boolean isFailFast()

setName

public void setName(java.lang.String theName)

getName

public java.lang.String getName()
Description copied from interface: ValidatorWrapper
Called to retrieve the "name" of the validator. The name represents some form of identification, though it does not have to be unique in any way. The name is merely associated with the configured validator, and is referenced when reporting failures.

Specified by:
getName in interface ValidatorWrapper
Returns:
Returns the name of this validator.

getDoc

public DocumentationIterator getDoc()
Called to retrieve the documentation for the validator.

Specified by:
getDoc in interface ValidatorWrapper
Returns:
Returns the documentation for the validator.

shouldIterate

protected abstract boolean shouldIterate(InternalValidatorContext context,
                                         ContextBean contextBean,
                                         java.lang.Object obj)
Determines whether we're iterating over the mapped object.

Parameters:
context - The ValidatorContext
contextBean - The ContextBean
obj - The object being validated.
Returns:
Returns true if we should iterate.

shouldExecute

protected abstract boolean shouldExecute(InternalValidatorContext context,
                                         ContextBean contextBean,
                                         java.lang.Object obj)
Determines whether the inclusion/call to the validation set should occur.

Parameters:
context - The ValidatorContext
contextBean - The ContextBean
obj - The object being validated.
Returns:
Returns true if the validation set should be called/executed.

mapObject

protected abstract java.lang.Object mapObject(InternalValidatorContext context,
                                              ContextBean contextBean,
                                              java.lang.Object obj)
Handle the mapping of the object being validated to the property that will be validated (may be the object, itself).

Parameters:
context - The ValidatorContext
contextBean - The ContextBean
obj - The object being validated.
Returns:
Returns the object that will be forwarded to the called validation set.

createNewContext

protected InternalValidatorContext createNewContext(ContextBean newContextBean,
                                                    java.util.Locale newLocale,
                                                    InternalValidatorContext oldContext)
Constructs a new context for the validation set being called.

Parameters:
newContextBean - The new ContextBean created for the validation set.
newLocale - The new Locale for the validation set.
oldContext - The old ValidatorContext from the current validation set.