org.hibernate.validator.engine
Class ValidationContext<T,C extends ConstraintViolation<T>>

java.lang.Object
  extended by org.hibernate.validator.engine.ValidationContext<T,C>
Direct Known Subclasses:
MethodValidationContext, StandardValidationContext

public abstract class ValidationContext<T,C extends ConstraintViolation<T>>
extends Object

Context object keeping track of all important data for a top level Validator.validate(Object, Class[]) }, Validator.validateValue(Class, String, Object, Class[]) } or Validator.validateProperty(Object, String, Class[]) call.

we use this object to collect all failing constraints, but also to cache the caching traversable resolver for a full stack call.

Author:
Hardy Ferentschik, Emmanuel Bernard, Gunnar Morling

Field Summary
protected  MessageInterpolator messageInterpolator
          The message resolver which should be used in this context.
 
Constructor Summary
protected ValidationContext(Class<T> rootBeanClass, T rootBean, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
 
Method Summary
 void addConstraintFailures(Set<C> failingConstraintViolations)
           
abstract
<U,V> C
createConstraintViolation(ValueContext<U,V> localContext, MessageAndPath messageAndPath, ConstraintDescriptor<?> descriptor)
           
<U,V> List<C>
createConstraintViolations(ValueContext<U,V> localContext, ConstraintValidatorContextImpl constraintValidatorContext)
           
 ConstraintValidatorFactory getConstraintValidatorFactory()
           
static
<T> ValidationContext<T,ConstraintViolation<T>>
getContextForValidate(T object, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
static
<T> MethodValidationContext<T>
getContextForValidateParameter(Method method, int parameterIndex, T object, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
static
<T> MethodValidationContext<T>
getContextForValidateParameters(Method method, T object, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
static
<T> ValidationContext<T,ConstraintViolation<T>>
getContextForValidateProperty(T rootBean, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
static
<T> ValidationContext<T,ConstraintViolation<T>>
getContextForValidateValue(Class<T> rootBeanClass, MessageInterpolator messageInterpolator, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver, boolean failFast)
           
 Set<C> getFailingConstraints()
           
 MessageInterpolator getMessageInterpolator()
           
 T getRootBean()
           
 Class<T> getRootBeanClass()
           
 TraversableResolver getTraversableResolver()
           
 boolean isAlreadyValidated(Object value, Class<?> group, PathImpl path)
           
 void markProcessed(Object value, Class<?> group, PathImpl path)
           
 boolean shouldFailFast()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageInterpolator

protected final MessageInterpolator messageInterpolator
The message resolver which should be used in this context.

Constructor Detail

ValidationContext

protected ValidationContext(Class<T> rootBeanClass,
                            T rootBean,
                            MessageInterpolator messageInterpolator,
                            ConstraintValidatorFactory constraintValidatorFactory,
                            TraversableResolver traversableResolver,
                            boolean failFast)
Method Detail

getContextForValidate

public static <T> ValidationContext<T,ConstraintViolation<T>> getContextForValidate(T object,
                                                                                    MessageInterpolator messageInterpolator,
                                                                                    ConstraintValidatorFactory constraintValidatorFactory,
                                                                                    TraversableResolver traversableResolver,
                                                                                    boolean failFast)

getContextForValidateProperty

public static <T> ValidationContext<T,ConstraintViolation<T>> getContextForValidateProperty(T rootBean,
                                                                                            MessageInterpolator messageInterpolator,
                                                                                            ConstraintValidatorFactory constraintValidatorFactory,
                                                                                            TraversableResolver traversableResolver,
                                                                                            boolean failFast)

getContextForValidateValue

public static <T> ValidationContext<T,ConstraintViolation<T>> getContextForValidateValue(Class<T> rootBeanClass,
                                                                                         MessageInterpolator messageInterpolator,
                                                                                         ConstraintValidatorFactory constraintValidatorFactory,
                                                                                         TraversableResolver traversableResolver,
                                                                                         boolean failFast)

getContextForValidateParameter

public static <T> MethodValidationContext<T> getContextForValidateParameter(Method method,
                                                                            int parameterIndex,
                                                                            T object,
                                                                            MessageInterpolator messageInterpolator,
                                                                            ConstraintValidatorFactory constraintValidatorFactory,
                                                                            TraversableResolver traversableResolver,
                                                                            boolean failFast)

getContextForValidateParameters

public static <T> MethodValidationContext<T> getContextForValidateParameters(Method method,
                                                                             T object,
                                                                             MessageInterpolator messageInterpolator,
                                                                             ConstraintValidatorFactory constraintValidatorFactory,
                                                                             TraversableResolver traversableResolver,
                                                                             boolean failFast)

getRootBean

public final T getRootBean()

getRootBeanClass

public final Class<T> getRootBeanClass()

getTraversableResolver

public final TraversableResolver getTraversableResolver()

getMessageInterpolator

public final MessageInterpolator getMessageInterpolator()

shouldFailFast

public final boolean shouldFailFast()

createConstraintViolation

public abstract <U,V> C createConstraintViolation(ValueContext<U,V> localContext,
                                                  MessageAndPath messageAndPath,
                                                  ConstraintDescriptor<?> descriptor)

createConstraintViolations

public final <U,V> List<C> createConstraintViolations(ValueContext<U,V> localContext,
                                                      ConstraintValidatorContextImpl constraintValidatorContext)

getConstraintValidatorFactory

public final ConstraintValidatorFactory getConstraintValidatorFactory()

isAlreadyValidated

public boolean isAlreadyValidated(Object value,
                                  Class<?> group,
                                  PathImpl path)

markProcessed

public void markProcessed(Object value,
                          Class<?> group,
                          PathImpl path)

addConstraintFailures

public final void addConstraintFailures(Set<C> failingConstraintViolations)

getFailingConstraints

public Set<C> getFailingConstraints()


Copyright © 2007-2011 Red Hat Middleware, LLC. All Rights Reserved