org.apache.bval.util
Class ValidationHelper

java.lang.Object
  extended by org.apache.bval.util.ValidationHelper

public class ValidationHelper
extends Object

Stateless helper methods used by the validators.

Author:
Carlos Vara

Nested Class Summary
static interface ValidationHelper.ValidateCallback
          Interface implemented by the call-back object passed to validateContext(ValidationContext, ValidateCallback, boolean) .
 
Constructor Summary
ValidationHelper()
           
 
Method Summary
protected static
<VL extends ValidationListener>
void
validateArrayInContext(ValidationContext<VL> context, ValidationHelper.ValidateCallback s)
          Iterates the values of an array, setting the current context appropriately and validating each value.
static
<VL extends ValidationListener>
void
validateBean(ValidationContext<VL> context)
          Validate a single bean only, no related beans will be validated.
protected static
<VL extends ValidationListener>
void
validateBeanInContext(ValidationContext<VL> context, ValidationHelper.ValidateCallback s)
          Validates a single object.
static void validateContext(ValidationContext<?> context, ValidationHelper.ValidateCallback s, boolean treatMapsLikeBeans)
          validate a complex 'bean' with related beans according to validation rules in 'metaBean'
protected static
<VL extends ValidationListener>
void
validateIterableInContext(ValidationContext<VL> context, ValidationHelper.ValidateCallback s)
          Iterates the values of an Iterable object, setting the current context appropriately and validating each value.
protected static
<VL extends ValidationListener>
void
validateMapInContext(ValidationContext<VL> context, ValidationHelper.ValidateCallback s)
          Iterates the values of a Map, setting the current context appropriately and validating each value.
static
<VL extends ValidationListener>
void
validateProperty(ValidationContext<VL> context)
          Validate a single property only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationHelper

public ValidationHelper()
Method Detail

validateContext

public static void validateContext(ValidationContext<?> context,
                                   ValidationHelper.ValidateCallback s,
                                   boolean treatMapsLikeBeans)
validate a complex 'bean' with related beans according to validation rules in 'metaBean'

Parameters:
context - - the context is initialized with:
  bean - the root object start validation at or a collection of root objects
  metaBean - the meta information for the root object(s)
context - The current validation context.

validateBeanInContext

protected static <VL extends ValidationListener> void validateBeanInContext(ValidationContext<VL> context,
                                                                            ValidationHelper.ValidateCallback s)
Validates a single object.

Type Parameters:
VL -
Parameters:
context - The validation context, its current bean must be a single object.
s -

validateArrayInContext

protected static <VL extends ValidationListener> void validateArrayInContext(ValidationContext<VL> context,
                                                                             ValidationHelper.ValidateCallback s)
Iterates the values of an array, setting the current context appropriately and validating each value.

Type Parameters:
VL -
Parameters:
context - The validation context, its current bean must be an array.

validateIterableInContext

protected static <VL extends ValidationListener> void validateIterableInContext(ValidationContext<VL> context,
                                                                                ValidationHelper.ValidateCallback s)
Iterates the values of an Iterable object, setting the current context appropriately and validating each value.

Type Parameters:
VL -
Parameters:
context - The validation context, its current bean must implement Iterable.

validateMapInContext

protected static <VL extends ValidationListener> void validateMapInContext(ValidationContext<VL> context,
                                                                           ValidationHelper.ValidateCallback s)
Iterates the values of a Map, setting the current context appropriately and validating each value.

Type Parameters:
VL -
Parameters:
context - The validation context, its current bean must implement Map.

validateBean

public static <VL extends ValidationListener> void validateBean(ValidationContext<VL> context)
Validate a single bean only, no related beans will be validated.


validateProperty

public static <VL extends ValidationListener> void validateProperty(ValidationContext<VL> context)
Validate a single property only. Performs all validations for this property.



Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.