com.opensymphony.xwork2.validator
Class AnnotationActionValidatorManager

java.lang.Object
  extended by com.opensymphony.xwork2.validator.AnnotationActionValidatorManager
All Implemented Interfaces:
ActionValidatorManager

public class AnnotationActionValidatorManager
extends java.lang.Object
implements ActionValidatorManager

AnnotationActionValidatorManager is the entry point into XWork's annotations-based validator framework. Validation rules are specified as annotations within the source files.

Author:
Rainer Hermanns, jepjep

Nested Class Summary
protected  class AnnotationActionValidatorManager.InternalValidatorContextWrapper
          An ValidatorContext wrapper that returns the full field name AnnotationActionValidatorManager.InternalValidatorContextWrapper.getFullFieldName(String) by consulting it's parent if its an VisitorFieldValidator.AppendingValidatorContext.
 
Field Summary
protected static java.lang.String VALIDATION_CONFIG_SUFFIX
          The file suffix for any validation file.
 
Constructor Summary
AnnotationActionValidatorManager()
           
 
Method Summary
protected  java.util.List<ValidatorConfig> buildClassValidatorConfigs(java.lang.Class aClass, boolean checkFile)
           
protected static java.lang.String buildValidatorKey(java.lang.Class clazz)
          Builds a key for validators - used when caching validators.
 java.util.List<Validator> getValidators(java.lang.Class clazz, java.lang.String context)
          Returns a list of validators for the given class and context.
 java.util.List<Validator> getValidators(java.lang.Class clazz, java.lang.String context, java.lang.String method)
          Returns a list of validators for the given class, context, and method.
 void setValidatorFactory(ValidatorFactory fac)
           
 void setValidatorFileParser(ValidatorFileParser parser)
           
 void validate(java.lang.Object object, java.lang.String context)
          Validates the given object using action and its context.
 void validate(java.lang.Object object, java.lang.String context, java.lang.String method)
          Validates the given object using an action, its context, and the name of the method being invoked on the action.
 void validate(java.lang.Object object, java.lang.String context, ValidatorContext validatorContext)
          Validates an action give its context and a validation context.
 void validate(java.lang.Object object, java.lang.String context, ValidatorContext validatorContext, java.lang.String method)
          Validates an action give its context and a validation context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATION_CONFIG_SUFFIX

protected static final java.lang.String VALIDATION_CONFIG_SUFFIX
The file suffix for any validation file.

See Also:
Constant Field Values
Constructor Detail

AnnotationActionValidatorManager

public AnnotationActionValidatorManager()
Method Detail

setValidatorFactory

public void setValidatorFactory(ValidatorFactory fac)

setValidatorFileParser

public void setValidatorFileParser(ValidatorFileParser parser)

getValidators

public java.util.List<Validator> getValidators(java.lang.Class clazz,
                                               java.lang.String context)
Description copied from interface: ActionValidatorManager
Returns a list of validators for the given class and context. This is the primary lookup method for validators.

Specified by:
getValidators in interface ActionValidatorManager
Parameters:
clazz - the class to lookup.
context - the context of the action class - can be null.
Returns:
a list of all validators for the given class and context.

getValidators

public java.util.List<Validator> getValidators(java.lang.Class clazz,
                                               java.lang.String context,
                                               java.lang.String method)
Description copied from interface: ActionValidatorManager
Returns a list of validators for the given class, context, and method. This is the primary lookup method for validators.

Specified by:
getValidators in interface ActionValidatorManager
Parameters:
clazz - the class to lookup.
context - the context of the action class - can be null.
method - the name of the method being invoked on the action - can be null.
Returns:
a list of all validators for the given class and context.

validate

public void validate(java.lang.Object object,
                     java.lang.String context)
              throws ValidationException
Description copied from interface: ActionValidatorManager
Validates the given object using action and its context.

Specified by:
validate in interface ActionValidatorManager
Parameters:
object - the action to validate.
context - the action's context.
Throws:
ValidationException - if an error happens when validating the action.

validate

public void validate(java.lang.Object object,
                     java.lang.String context,
                     java.lang.String method)
              throws ValidationException
Description copied from interface: ActionValidatorManager
Validates the given object using an action, its context, and the name of the method being invoked on the action.

Specified by:
validate in interface ActionValidatorManager
Parameters:
object - the action to validate.
context - the action's context.
method - the name of the method being invoked on the action - can be null.
Throws:
ValidationException - if an error happens when validating the action.

validate

public void validate(java.lang.Object object,
                     java.lang.String context,
                     ValidatorContext validatorContext)
              throws ValidationException
Description copied from interface: ActionValidatorManager
Validates an action give its context and a validation context.

Specified by:
validate in interface ActionValidatorManager
Parameters:
object - the action to validate.
context - the action's context.
validatorContext - the validation context to use
Throws:
ValidationException - if an error happens when validating the action.

validate

public void validate(java.lang.Object object,
                     java.lang.String context,
                     ValidatorContext validatorContext,
                     java.lang.String method)
              throws ValidationException
Description copied from interface: ActionValidatorManager
Validates an action give its context and a validation context.

Specified by:
validate in interface ActionValidatorManager
Parameters:
object - the action to validate.
context - the action's context.
validatorContext - the validation context to use
method - the name of the method being invoked on the action - can be null.
Throws:
ValidationException - if an error happens when validating the action.

buildValidatorKey

protected static java.lang.String buildValidatorKey(java.lang.Class clazz)
Builds a key for validators - used when caching validators.

Parameters:
clazz - the action.
Returns:
a validator key which is the class name plus context.

buildClassValidatorConfigs

protected java.util.List<ValidatorConfig> buildClassValidatorConfigs(java.lang.Class aClass,
                                                                     boolean checkFile)


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.