com.opensymphony.xwork2.validator

## Class DefaultActionValidatorManager

- java.lang.Object
- - com.opensymphony.xwork2.validator.DefaultActionValidatorManager

- All Implemented Interfaces:
    ActionValidatorManager

      public class DefaultActionValidatorManager
      extends Object
      implements ActionValidatorManager

  This is the entry point into XWork's rule-based validation framework.

  Validation rules are specified in XML configuration files named `className-contextName-validation.xml` where className is the name of the class the configuration is for and -contextName is optional (contextName is an arbitrary key that is used to look up additional validation rules for a specific context).

  Author:
    Jason Carreira, Mark Woon, James House, Rainer Hermanns

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `VALIDATION_CONFIG_SUFFIX` The file suffix for any validation file.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultActionValidatorManager()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static String` | `buildValidatorKey(Class clazz, String context)` Builds a key for validators - used when caching validators.
    `List<Validator>` | `getValidators(Class clazz, String context)` Returns a list of validators for the given class and context.
    `List<Validator>` | `getValidators(Class clazz, String context, String method)` Returns a list of validators for the given class, context, and method.
    `void` | `setFileManagerFactory(FileManagerFactory fileManagerFactory)`
    `void` | `setReloadingConfigs(String reloadingConfigs)`
    `void` | `setTextProviderFactory(TextProviderFactory textProviderFactory)`
    `void` | `setValidatorFactory(ValidatorFactory fac)`
    `void` | `setValidatorFileParser(ValidatorFileParser parser)`
    `void` | `validate(Object object, String context)` Validates the given object using action and its context.
    `void` | `validate(Object object, String context, String method)` Validates the given object using an action, its context, and the name of the method being invoked on the action.
    `void` | `validate(Object object, String context, ValidatorContext validatorContext)` Validates an action give its context and a validation context.
    `void` | `validate(Object object, String context, ValidatorContext validatorContext, 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 String VALIDATION_CONFIG_SUFFIX

      The file suffix for any validation file.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DefaultActionValidatorManager

          public DefaultActionValidatorManager()

  - ### Method Detail

    - #### setValidatorFileParser

          public void setValidatorFileParser(ValidatorFileParser parser)

    - #### setValidatorFactory

          public void setValidatorFactory(ValidatorFactory fac)

    - #### setFileManagerFactory

          public void setFileManagerFactory(FileManagerFactory fileManagerFactory)

    - #### setReloadingConfigs

          public void setReloadingConfigs(String reloadingConfigs)

    - #### setTextProviderFactory

          public void setTextProviderFactory(TextProviderFactory textProviderFactory)

    - #### getValidators

          public List<Validator> getValidators(Class clazz,
                                      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 List<Validator> getValidators(Class clazz,
                                      String context,
                                      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(Object object,
                      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(Object object,
                      String context,
                      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(Object object,
                      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(Object object,
                      String context,
                      ValidatorContext validatorContext,
                      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 String buildValidatorKey(Class clazz,
                                 String context)

      Builds a key for validators - used when caching validators.
      Parameters:
        `clazz` - the action.
        `context` - the action's context.
      Returns:
        a validator key which is the class name plus context.

Copyright © 2000–2021 Apache Software Foundation. All rights reserved.