org.springmodules.validation.commons
Class AbstractBeanValidator

java.lang.Object
  extended by org.springmodules.validation.commons.AbstractBeanValidator
All Implemented Interfaces:
Validator
Direct Known Subclasses:
AbstractPageBeanValidator, ConfigurableBeanValidator, DefaultBeanValidator

public abstract class AbstractBeanValidator
extends Object
implements Validator

Author:
Rob Harrop

Constructor Summary
AbstractBeanValidator()
           
 
Method Summary
protected  void cleanupValidator(org.apache.commons.validator.Validator validator)
          A callback method that is called just after the validate() method is called on the given validator.
protected abstract  String getFormName(Class aClass)
          Returns the name of the Commons Validator Form used to validate instances of the supplied class.
protected  Locale getLocale()
          Gets the Locale used to lookup Validator instances.
protected  void initValidator(org.apache.commons.validator.Validator validator)
          A callback method that is called just before the validate() method is called on the given validator.
 void setValidatorFactory(ValidatorFactory validatorFactory)
           
 boolean supports(Class clazz)
          Checks if the validatorFactory is configured to handle this class.
 void validate(Object obj, Errors errors)
          Validates the supplied object using a org.apache.commons.validator.Validator loaded from the configured ValidatorFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBeanValidator

public AbstractBeanValidator()
Method Detail

supports

public boolean supports(Class clazz)
Checks if the validatorFactory is configured to handle this class. Will convert the class into a form name, suitable for commons validator.

Specified by:
supports in interface Validator
Returns:
true if the validatorFactory supports the class, or false if not
See Also:
getFormName(Class)

validate

public void validate(Object obj,
                     Errors errors)
Validates the supplied object using a org.apache.commons.validator.Validator loaded from the configured ValidatorFactory.

Specified by:
validate in interface Validator
See Also:
ValidatorFactory

setValidatorFactory

public void setValidatorFactory(ValidatorFactory validatorFactory)

getLocale

protected Locale getLocale()
Gets the Locale used to lookup Validator instances. Default implementation returns the value of Locale.getDefault(). Subclasses can override this to change Locale-handling behavior.


initValidator

protected void initValidator(org.apache.commons.validator.Validator validator)
A callback method that is called just before the validate() method is called on the given validator. This can be used to further configure the validator.

Parameters:
validator -

cleanupValidator

protected void cleanupValidator(org.apache.commons.validator.Validator validator)
A callback method that is called just after the validate() method is called on the given validator. This method can be used to clean up all the extra configuration added in the initValidator(org.apache.commons.validator.Validator) method.

Parameters:
validator -

getFormName

protected abstract String getFormName(Class aClass)
Returns the name of the Commons Validator Form used to validate instances of the supplied class.

Parameters:
aClass -
Returns:
the form name that Commons Validator can use to look up a form


Copyright © 2009. All Rights Reserved.