com.opensymphony.xwork2.validator.validators

## Class ValidatorSupport

- java.lang.Object
- - com.opensymphony.xwork2.validator.validators.ValidatorSupport

- All Implemented Interfaces:
    ShortCircuitableValidator, Validator
  Direct Known Subclasses:
    ExpressionValidator, FieldValidatorSupport

      public abstract class ValidatorSupport
      extends Object
      implements Validator, ShortCircuitableValidator

  Abstract implementation of the Validator interface suitable for subclassing.
  Author:
    Jason Carreira, tm_jee, Martin Gilday

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `defaultMessage`
    `static String` | `EMPTY_STRING`
    `protected String` | `messageKey`
    `protected ValueStack` | `stack`
    `protected TextProviderFactory` | `textProviderFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValidatorSupport()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addActionError(Object object)`
    `protected void` | `addFieldError(String propertyName, Object object)`
    `String` | `getDefaultMessage()` Gets the default message used for validation failures
    `protected Object` | `getFieldValue(String name, Object object)` Return the field value named `name` from `object`, `object` should have the appropriate getter/setter.
    `String` | `getMessage(Object object)` Gets the validation failure message for the given object
    `String` | `getMessageKey()` Gets the resource bundle key used for lookup of validation failure message
    `String[]` | `getMessageParameters()` Gets the message parameters to be used when parsing i18n messages
    `ValidatorContext` | `getValidatorContext()` Gets the validation context used
    `String` | `getValidatorType()` Gets the validator type used (see class javadoc).
    `boolean` | `isShortCircuit()` Gets whether this field validator should short circuit the validator queue it's in if validation fails.
    `protected Object` | `parse(String expression, Class type)` Parse `expression` passed in against value stack.
    `void` | `setDefaultMessage(String message)` Sets the default message to use for validation failure
    `void` | `setMessageKey(String key)` Sets a resource bundle key to be used for lookup of validation failure message
    `void` | `setMessageParameters(String[] messageParameters)` Sets the message parameters to be used when parsing i18n messages
    `void` | `setShortCircuit(boolean shortcircuit)` Sets whether this field validator should short circuit the validator queue it's in if validation fails.
    `void` | `setTextProviderFactory(TextProviderFactory textProviderFactory)`
    `void` | `setValidatorContext(ValidatorContext validatorContext)` This method will be called before validate with a non-null ValidatorContext.
    `void` | `setValidatorType(String type)` Sets the validator type to use (see class javadoc).
    `void` | `setValueStack(ValueStack stack)` Sets the value stack to use to resolve values and parameters

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.opensymphony.xwork2.validator.Validator

      `validate`

- - ### Field Detail

    - #### EMPTY_STRING

          public static final String EMPTY_STRING

      See Also:
        Constant Field Values

    - #### defaultMessage

          protected String defaultMessage

    - #### messageKey

          protected String messageKey

    - #### stack

          protected ValueStack stack

    - #### textProviderFactory

          protected TextProviderFactory textProviderFactory

  - ### Constructor Detail

    - #### ValidatorSupport

          public ValidatorSupport()

  - ### Method Detail

    - #### setTextProviderFactory

          public void setTextProviderFactory(TextProviderFactory textProviderFactory)

    - #### setValueStack

          public void setValueStack(ValueStack stack)

      Description copied from interface: `Validator`
      Sets the value stack to use to resolve values and parameters
      Specified by:
        `setValueStack` in interface `Validator`
      Parameters:
        `stack` - The value stack for the request

    - #### setDefaultMessage

          public void setDefaultMessage(String message)

      Description copied from interface: `Validator`
      Sets the default message to use for validation failure
      Specified by:
        `setDefaultMessage` in interface `Validator`
      Parameters:
        `message` - the default message

    - #### getDefaultMessage

          public String getDefaultMessage()

      Description copied from interface: `Validator`
      Gets the default message used for validation failures
      Specified by:
        `getDefaultMessage` in interface `Validator`
      Returns:
        the default message

    - #### getMessage

          public String getMessage(Object object)

      Description copied from interface: `Validator`
      Gets the validation failure message for the given object
      Specified by:
        `getMessage` in interface `Validator`
      Parameters:
        `object` - object being validated (eg. a domain model object)
      Returns:
        the validation failure message

    - #### setMessageKey

          public void setMessageKey(String key)

      Description copied from interface: `Validator`
      Sets a resource bundle key to be used for lookup of validation failure message
      Specified by:
        `setMessageKey` in interface `Validator`
      Parameters:
        `key` - the resource bundle key

    - #### getMessageKey

          public String getMessageKey()

      Description copied from interface: `Validator`
      Gets the resource bundle key used for lookup of validation failure message
      Specified by:
        `getMessageKey` in interface `Validator`
      Returns:
        the resource bundle key

    - #### getMessageParameters

          public String[] getMessageParameters()

      Description copied from interface: `Validator`
      Gets the message parameters to be used when parsing i18n messages
      Specified by:
        `getMessageParameters` in interface `Validator`
      Returns:
        the message parameters

    - #### setMessageParameters

          public void setMessageParameters(String[] messageParameters)

      Description copied from interface: `Validator`
      Sets the message parameters to be used when parsing i18n messages
      Specified by:
        `setMessageParameters` in interface `Validator`
      Parameters:
        `messageParameters` - the message parameters

    - #### setShortCircuit

          public void setShortCircuit(boolean shortcircuit)

      Description copied from interface: `ShortCircuitableValidator`
      Sets whether this field validator should short circuit the validator queue it's in if validation fails.
      Specified by:
        `setShortCircuit` in interface `ShortCircuitableValidator`
      Parameters:
        `shortcircuit` - `true` if this field validator should short circuit on failure, `false` otherwise

    - #### isShortCircuit

          public boolean isShortCircuit()

      Description copied from interface: `ShortCircuitableValidator`
      Gets whether this field validator should short circuit the validator queue it's in if validation fails.
      Specified by:
        `isShortCircuit` in interface `ShortCircuitableValidator`
      Returns:
        `true` if this field validator should short circuit on failure, `false` otherwise

    - #### setValidatorContext

          public void setValidatorContext(ValidatorContext validatorContext)

      Description copied from interface: `Validator`
      This method will be called before validate with a non-null ValidatorContext.
      Specified by:
        `setValidatorContext` in interface `Validator`
      Parameters:
        `validatorContext` - the validation context to use.

    - #### getValidatorContext

          public ValidatorContext getValidatorContext()

      Description copied from interface: `Validator`
      Gets the validation context used
      Specified by:
        `getValidatorContext` in interface `Validator`
      Returns:
        the validation context

    - #### setValidatorType

          public void setValidatorType(String type)

      Description copied from interface: `Validator`
      Sets the validator type to use (see class javadoc).
      Specified by:
        `setValidatorType` in interface `Validator`
      Parameters:
        `type` - the type to use.

    - #### getValidatorType

          public String getValidatorType()

      Description copied from interface: `Validator`
      Gets the validator type used (see class javadoc).
      Specified by:
        `getValidatorType` in interface `Validator`
      Returns:
        the type used

    - #### parse

          protected Object parse(String expression,
                     Class type)

      Parse `expression` passed in against value stack.
      Parameters:
        `expression` - an OGNL expression
        `type` - type to return
      Returns:
        Object

    - #### getFieldValue

          protected Object getFieldValue(String name,
                             Object object)
                                  throws ValidationException

      Return the field value named `name` from `object`, `object` should have the appropriate getter/setter.
      Parameters:
        `name` - name of the field
        `object` - to search field name on
      Returns:
        Object as field value
      Throws:
        `ValidationException` - in case of validation problems

    - #### addActionError

          protected void addActionError(Object object)

    - #### addFieldError

          protected void addFieldError(String propertyName,
                           Object object)

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