com.google.gwt.validation.client
Class AbstractValidator<T>

java.lang.Object
  extended by com.google.gwt.validation.client.AbstractValidator<T>
Type Parameters:
IValidatable - the validatable class to validate
All Implemented Interfaces:
IValidator<T>
Direct Known Subclasses:
ServerValidator

public abstract class AbstractValidator<T>
extends java.lang.Object
implements IValidator<T>

Wrapper for IValidator that contains utility methods for validation

Author:
chris

Constructor Summary
AbstractValidator()
           
 
Method Summary
protected  java.util.ArrayList<java.lang.String> arrayToList(java.lang.String... inputArray)
          I'm fairly certain this exists elsewhere but I want to use it in this context to be GWT safe and not rely on emulation.
protected abstract  java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> getGroupSequenceMapping(java.lang.Class<?> inputClass)
          Gets the group sequence mapping from the implementing class
protected  boolean intersects(java.util.Collection<? extends java.lang.Object> collectionA, java.util.Collection<? extends java.lang.Object> collectionB)
          Returns true if and only if list A intersects list B at one or more points.
abstract  java.util.Set<InvalidConstraint<T>> performValidation(T object, java.lang.String propertyName, java.util.ArrayList<java.lang.String> groups, java.util.HashSet<java.lang.String> processedGroups, java.util.HashSet<java.lang.String> processedObjects)
          Actual validation engine class that performs validation internally
protected  java.util.Set<InvalidConstraint<T>> prepareValidation(T object, java.lang.String propertyName, java.lang.Object inputValue, java.util.ArrayList<java.lang.String> groups)
          Group level validation performed for pre-processing of the engine.
protected
<X> InvalidConstraint<T>
unrollConstraint(T object, java.lang.String property, InvalidConstraint<X> insideConstraint)
          Turns an invalid constraint at a lower level to one at the proper higher level
protected
<X> java.util.Set<InvalidConstraint<T>>
unrollConstraintSet(T object, java.lang.String property, java.util.Set<InvalidConstraint<X>> insideConstraintSet)
          Uses unrollConstraint to unroll an entire set and return them as a set of invalid constraints and return them as a set of the type that corresponds to this validator.
 java.util.Set<InvalidConstraint<T>> validate(T object, java.lang.String... groups)
          validate all constraints on object
protected  java.util.Set<InvalidConstraint<T>> validateProperty(T object, java.lang.String propertyName, java.util.ArrayList<java.lang.String> groups)
          Validate the property like the interface but accept an array list instead of an array
 java.util.Set<InvalidConstraint<T>> validateProperty(T object, java.lang.String propertyName, java.lang.String... groups)
          validate all constraints on propertyName property of object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractValidator

public AbstractValidator()
Method Detail

getGroupSequenceMapping

protected abstract java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> getGroupSequenceMapping(java.lang.Class<?> inputClass)
Gets the group sequence mapping from the implementing class

Parameters:
inputClass -
Returns:

performValidation

public abstract java.util.Set<InvalidConstraint<T>> performValidation(T object,
                                                                      java.lang.String propertyName,
                                                                      java.util.ArrayList<java.lang.String> groups,
                                                                      java.util.HashSet<java.lang.String> processedGroups,
                                                                      java.util.HashSet<java.lang.String> processedObjects)
Actual validation engine class that performs validation internally

Parameters:
object -
propertyName -
groups -
processedGroups -
processedObjects -
Returns:

validate

public java.util.Set<InvalidConstraint<T>> validate(T object,
                                                    java.lang.String... groups)
Description copied from interface: IValidator
validate all constraints on object

Specified by:
validate in interface IValidator<T>
Parameters:
object - object to validate
groups - group name(s) targeted for validation (default to default)
Returns:
invalid constrains or an empty Set if none

validateProperty

public java.util.Set<InvalidConstraint<T>> validateProperty(T object,
                                                            java.lang.String propertyName,
                                                            java.lang.String... groups)
Description copied from interface: IValidator
validate all constraints on propertyName property of object

Specified by:
validateProperty in interface IValidator<T>
Parameters:
object - object to validate
propertyName - property to validate
groups - group name(s) targeted for validation (default to default)
Returns:
invalid constrains or an empty Set if none

validateProperty

protected java.util.Set<InvalidConstraint<T>> validateProperty(T object,
                                                               java.lang.String propertyName,
                                                               java.util.ArrayList<java.lang.String> groups)
Validate the property like the interface but accept an array list instead of an array

Parameters:
object -
propertyName -
groups -
Returns:

prepareValidation

protected java.util.Set<InvalidConstraint<T>> prepareValidation(T object,
                                                                java.lang.String propertyName,
                                                                java.lang.Object inputValue,
                                                                java.util.ArrayList<java.lang.String> groups)
Group level validation performed for pre-processing of the engine.

Parameters:
object -
propertyName -
groups -
Returns:

intersects

protected boolean intersects(java.util.Collection<? extends java.lang.Object> collectionA,
                             java.util.Collection<? extends java.lang.Object> collectionB)
Returns true if and only if list A intersects list B at one or more points.

Parameters:
collectionA - collection of values A
collectionB - collection of values B
Returns:

arrayToList

protected java.util.ArrayList<java.lang.String> arrayToList(java.lang.String... inputArray)
I'm fairly certain this exists elsewhere but I want to use it in this context to be GWT safe and not rely on emulation. Also to be null or empty safe.

Parameters:
inputArray -
Returns:

unrollConstraint

protected <X> InvalidConstraint<T> unrollConstraint(T object,
                                                    java.lang.String property,
                                                    InvalidConstraint<X> insideConstraint)
Turns an invalid constraint at a lower level to one at the proper higher level

Type Parameters:
X -
Returns:

unrollConstraintSet

protected <X> java.util.Set<InvalidConstraint<T>> unrollConstraintSet(T object,
                                                                      java.lang.String property,
                                                                      java.util.Set<InvalidConstraint<X>> insideConstraintSet)
Uses unrollConstraint to unroll an entire set and return them as a set of invalid constraints and return them as a set of the type that corresponds to this validator.

Type Parameters:
X -
Parameters:
object -
property -
insideConstraintSet -
Returns: