org.springmodules.validation.commons
Class DefaultValidatorFactory

java.lang.Object
  extended by org.springmodules.validation.commons.DefaultValidatorFactory
All Implemented Interfaces:
InitializingBean, ValidatorFactory

public class DefaultValidatorFactory
extends Object
implements ValidatorFactory, InitializingBean

Author:
Daniel Miller, Rob Harrop

Field Summary
static String ERRORS_KEY
          Key used to store the Spring Errors instance in the Validator
 
Constructor Summary
DefaultValidatorFactory()
           
 
Method Summary
 void afterPropertiesSet()
          Checks that the ValidatorResources exists and has been configured with resources via a call to setValidationConfigLocations.
 org.apache.commons.validator.Validator getValidator(String beanName, Object bean, Errors errors)
          Gets a new instance of a org.apache.commons.validator.Validator for the given bean.
 org.apache.commons.validator.ValidatorResources getValidatorResources()
          Gets the managed instance of ValidatorResources.
 boolean hasRulesForBean(String beanName, Locale locale)
          Returns true if this validator factory can create a validator that supports the given beanName and locale.
 void setValidationConfigLocations(Resource[] validationConfigLocations)
          Sets the locations of the validation configuration files from which to load validation rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERRORS_KEY

public static final String ERRORS_KEY
Key used to store the Spring Errors instance in the Validator

See Also:
Constant Field Values
Constructor Detail

DefaultValidatorFactory

public DefaultValidatorFactory()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Checks that the ValidatorResources exists and has been configured with resources via a call to setValidationConfigLocations.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
FatalBeanException - if setValidationConfigLocations() has not been called.
Exception

setValidationConfigLocations

public void setValidationConfigLocations(Resource[] validationConfigLocations)
Sets the locations of the validation configuration files from which to load validation rules. Creates an instance of ValidatorResources from the specified configuration files.

See Also:
Resource, ValidatorResources

getValidator

public org.apache.commons.validator.Validator getValidator(String beanName,
                                                           Object bean,
                                                           Errors errors)
Gets a new instance of a org.apache.commons.validator.Validator for the given bean.

Specified by:
getValidator in interface ValidatorFactory
Parameters:
beanName - The name of the bean for which this Validator will be created
See Also:
Validator

hasRulesForBean

public boolean hasRulesForBean(String beanName,
                               Locale locale)
Returns true if this validator factory can create a validator that supports the given beanName and locale.

Specified by:
hasRulesForBean in interface ValidatorFactory
Parameters:
beanName - name of the bean to be validated.
locale - Locale to search under.
Returns:
true if this validator factory can create a validator for the given bean name, false otherwise.

getValidatorResources

public org.apache.commons.validator.ValidatorResources getValidatorResources()
Gets the managed instance of ValidatorResources.

Specified by:
getValidatorResources in interface ValidatorFactory
Returns:
Returns the validatorResources.


Copyright © 2009. All Rights Reserved.