org.springmodules.validation.validator
Class CompoundValidator

java.lang.Object
  extended by org.springmodules.validation.validator.CompoundValidator
All Implemented Interfaces:
Validator

public class CompoundValidator
extends Object
implements Validator

A validator that is compound of aother validators. This validator deligates the validation task to all its contained validators.

Author:
Uri Boness

Constructor Summary
CompoundValidator()
          Constructs a new CompoundValidator with no internal validators.
CompoundValidator(Validator[] validators)
          Constructs a new CompoundValidator with the given internal validators.
 
Method Summary
 void addValidator(Validator validator)
          Adds the given validator to this compound validator.
 void addValidators(Validator[] validators)
          Adds the given validators to this compound validator.
 void setValidators(Validator[] validators)
          Sets the internal validators of this compound validator.
 boolean supports(Class clazz)
          Returns whether this validator supports the given class.
 void validate(Object obj, Errors errors)
          Validates the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundValidator

public CompoundValidator()
Constructs a new CompoundValidator with no internal validators.


CompoundValidator

public CompoundValidator(Validator[] validators)
Constructs a new CompoundValidator with the given internal validators.

Parameters:
validators - The internal validators this validator is compound of.
Method Detail

supports

public boolean supports(Class clazz)
Returns whether this validator supports the given class. In practice this validator supports the given class only if any of its internal validators support it.

Specified by:
supports in interface Validator
Parameters:
clazz - The class to be validated.
Returns:
Whether this validator supports the given class.
See Also:
Validator.supports(Class)

validate

public void validate(Object obj,
                     Errors errors)
Validates the given object. All internal validators that support the given object class will perform the actual validation.

Specified by:
validate in interface Validator
Parameters:
obj - The validated object.
errors - A registry where validation errors are registered.
See Also:
Validator.validate(Object, org.springframework.validation.Errors)

addValidator

public void addValidator(Validator validator)
Adds the given validator to this compound validator.

Parameters:
validator - The validator to be added to this compound validator.

addValidators

public void addValidators(Validator[] validators)
Adds the given validators to this compound validator.

Parameters:
validators - The validators to be added to this compound validator.

setValidators

public void setValidators(Validator[] validators)
Sets the internal validators of this compound validator.

Parameters:
validators - The internal validators of this compound validator.


Copyright © 2009. All Rights Reserved.