org.apache.bval.jsr303
Class ApacheValidatorFactory

java.lang.Object
  extended by org.apache.bval.jsr303.ApacheValidatorFactory
All Implemented Interfaces:
Cloneable, ValidatorFactory

public class ApacheValidatorFactory
extends Object
implements ValidatorFactory, Cloneable

Description: a factory is a complete configurated object that can create validators.
This instance is not thread-safe.


Constructor Summary
ApacheValidatorFactory(ConfigurationState configurationState)
          Create a new ApacheValidatorFactory instance.
 
Method Summary
 void addDefaultSequence(Class<?> beanClass, Class<?>[] groupSequence)
          Set the default group sequence for a particular bean class.
 void addMetaConstraint(Class<?> beanClass, MetaConstraint<?,?> metaConstraint)
          Add a meta-constraint to this ApacheValidatorFactory's runtime customizations.
 void addValid(Class<?> beanClass, AccessStrategy accessStrategy)
          Mark a property of beanClass for nested validation.
 ApacheValidatorFactory clone()
          
protected  void configure(ConfigurationState configuration)
          Configure this ApacheValidatorFactory from a ConfigurationState.
 AnnotationIgnores getAnnotationIgnores()
          Get the detected AnnotationIgnores.
 ConstraintCached getConstraintsCache()
          Get the constraint cache used.
 ConstraintValidatorFactory getConstraintValidatorFactory()
          
static ApacheValidatorFactory getDefault()
          Convenience method to retrieve a default global ApacheValidatorFactory
 ConstraintDefaults getDefaultConstraints()
          Get the detected ConstraintDefaults.
protected  MessageInterpolator getDefaultMessageInterpolator()
          Get the default MessageInterpolator used by this ApacheValidatorFactory.
 Class<?>[] getDefaultSequence(Class<?> beanClass)
          Get the default group sequence configured for beanClass.
 MessageInterpolator getMessageInterpolator()
          
<T> List<MetaConstraint<T,? extends Annotation>>
getMetaConstraints(Class<T> beanClass)
          Retrieve the runtime constraint configuration for a given class.
 Map<String,String> getProperties()
          Get the property map of this ApacheValidatorFactory.
 TraversableResolver getTraversableResolver()
          
 List<AccessStrategy> getValidAccesses(Class<?> beanClass)
          Get the AccessStrategy List indicating nested bean validations that must be triggered in the course of validating a beanClass graph.
 Validator getValidator()
          Shortcut method to create a new Validator instance with factory's settings
 void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
          Set the ConstraintValidatorFactory used.
static void setDefault(ApacheValidatorFactory aDefaultFactory)
          Set a particular ApacheValidatorFactory instance as the default.
 void setMessageInterpolator(MessageInterpolator messageResolver)
          Set the MessageInterpolator used.
 void setTraversableResolver(TraversableResolver traversableResolver)
          Set the TraversableResolver used.
<T> T
unwrap(Class<T> type)
          Return an object of the specified type to allow access to the provider-specific API.
 ApacheFactoryContext usingContext()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheValidatorFactory

public ApacheValidatorFactory(ConfigurationState configurationState)
Create a new ApacheValidatorFactory instance.

Method Detail

getDefault

public static ApacheValidatorFactory getDefault()
Convenience method to retrieve a default global ApacheValidatorFactory

Returns:
ApacheValidatorFactory

setDefault

public static void setDefault(ApacheValidatorFactory aDefaultFactory)
Set a particular ApacheValidatorFactory instance as the default.

Parameters:
aDefaultFactory -

configure

protected void configure(ConfigurationState configuration)
Configure this ApacheValidatorFactory from a ConfigurationState.

Parameters:
configuration -

getProperties

public Map<String,String> getProperties()
Get the property map of this ApacheValidatorFactory.

Returns:
Map

getDefaultMessageInterpolator

protected MessageInterpolator getDefaultMessageInterpolator()
Get the default MessageInterpolator used by this ApacheValidatorFactory.

Returns:
MessageInterpolator

getValidator

public Validator getValidator()
Shortcut method to create a new Validator instance with factory's settings

Specified by:
getValidator in interface ValidatorFactory
Returns:
the new validator instance

usingContext

public ApacheFactoryContext usingContext()

Specified by:
usingContext in interface ValidatorFactory
Returns:
the validator factory's context

clone

public ApacheValidatorFactory clone()

Overrides:
clone in class Object

setMessageInterpolator

public final void setMessageInterpolator(MessageInterpolator messageResolver)
Set the MessageInterpolator used.

Parameters:
messageResolver -

getMessageInterpolator

public MessageInterpolator getMessageInterpolator()

Specified by:
getMessageInterpolator in interface ValidatorFactory

setTraversableResolver

public final void setTraversableResolver(TraversableResolver traversableResolver)
Set the TraversableResolver used.

Parameters:
traversableResolver -

getTraversableResolver

public TraversableResolver getTraversableResolver()

Specified by:
getTraversableResolver in interface ValidatorFactory

setConstraintValidatorFactory

public final void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
Set the ConstraintValidatorFactory used.

Parameters:
constraintValidatorFactory -

getConstraintValidatorFactory

public ConstraintValidatorFactory getConstraintValidatorFactory()

Specified by:
getConstraintValidatorFactory in interface ValidatorFactory

unwrap

public <T> T unwrap(Class<T> type)
Return an object of the specified type to allow access to the provider-specific API. If the Bean Validation provider implementation does not support the specified class, the ValidationException is thrown.

Specified by:
unwrap in interface ValidatorFactory
Parameters:
type - the class of the object to be returned.
Returns:
an instance of the specified class
Throws:
ValidationException - if the provider does not support the call.

getDefaultConstraints

public ConstraintDefaults getDefaultConstraints()
Get the detected ConstraintDefaults.

Returns:
ConstraintDefaults

getAnnotationIgnores

public AnnotationIgnores getAnnotationIgnores()
Get the detected AnnotationIgnores.

Returns:
AnnotationIgnores

getConstraintsCache

public ConstraintCached getConstraintsCache()
Get the constraint cache used.

Returns:
ConstraintCached

addMetaConstraint

public void addMetaConstraint(Class<?> beanClass,
                              MetaConstraint<?,?> metaConstraint)
Add a meta-constraint to this ApacheValidatorFactory's runtime customizations.

Parameters:
beanClass -
metaConstraint -

addValid

public void addValid(Class<?> beanClass,
                     AccessStrategy accessStrategy)
Mark a property of beanClass for nested validation.

Parameters:
beanClass -
accessStrategy - defining the property to validate

addDefaultSequence

public void addDefaultSequence(Class<?> beanClass,
                               Class<?>[] groupSequence)
Set the default group sequence for a particular bean class.

Parameters:
beanClass -
groupSequence -

getMetaConstraints

public <T> List<MetaConstraint<T,? extends Annotation>> getMetaConstraints(Class<T> beanClass)
Retrieve the runtime constraint configuration for a given class.

Type Parameters:
T -
Parameters:
beanClass -
Returns:
List of MetaConstraints applicable to beanClass

getValidAccesses

public List<AccessStrategy> getValidAccesses(Class<?> beanClass)
Get the AccessStrategy List indicating nested bean validations that must be triggered in the course of validating a beanClass graph.

Parameters:
beanClass -
Returns:
List of AccessStrategy

getDefaultSequence

public Class<?>[] getDefaultSequence(Class<?> beanClass)
Get the default group sequence configured for beanClass.

Parameters:
beanClass -
Returns:
group Class array


Copyright © 2010-2012 Apache Software Foundation. All Rights Reserved.