org.apache.myfaces.trinidad.validator

## Class LengthValidator

- java.lang.Object
- - javax.faces.validator.LengthValidator
  - - org.apache.myfaces.trinidad.validator.LengthValidator

- All Implemented Interfaces:
    EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator

      public class LengthValidator
      extends javax.faces.validator.LengthValidator

  Implementation for length of `java.lang.String` values.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `EXACT_MESSAGE_ID` The message identifier of the `FacesMessage` to be created if the maximum and minimum lengths are the same, and the length check fails, and both the maximum and minimum values for this validator have been set.
    `static String` | `MAXIMUM_MESSAGE_ID` The message identifier of the `FacesMessage` to be created if the maximum length check fails.
    `static String` | `MINIMUM_MESSAGE_ID` The message identifier of the `FacesMessage` to be created if the minimum length check fails.
    `static String` | `NOT_IN_RANGE_MESSAGE_ID` The message identifier of the `FacesMessage` to be created if the maximum or minimum length check fails, and both the maximum and minimum lengths for this validator have been set.
    `static String` | `VALIDATOR_ID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LengthValidator()` Construct a `Validator` with no preconfigured limits.
    `LengthValidator(int maximum)` Construct a `Validator` with the specified preconfigured limit.
    `LengthValidator(int maximum, int minimum)` Construct a `Validator` with the specified preconfigured limits.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getHintExact()` Return custom hint exact message.
    `String` | `getHintMaximum()` Return custom hint maximum message.
    `String` | `getHintMinimum()` Return custom hint minimum message.
    `String` | `getHintNotInRange()` Return custom hint notInRange message.
    `int` | `getMaximum()` Return the maximum length to be enforced by this `Validator` or null if it has not been set.
    `String` | `getMessageDetailExact()` Return custom detail error message that was set for creating `FacesMessage`, for cases where the maximum and minimum lengths are the same, and the input length does not match.
    `String` | `getMessageDetailMaximum()` Return custom detail error message that was set for creating `FacesMessage`, for cases where input length exceeds the `maximum` length set.
    `String` | `getMessageDetailMinimum()` Return custom detail error message that was set for creating `FacesMessage`, for cases where, input length is less than the `minimum` length set.
    `String` | `getMessageDetailNotInRange()` Return custom detail error message that was set for creating `FacesMessage`, for cases where, input length exceeds the `maximum` length and is less than the `minimum` length set.
    `int` | `getMinimum()` Return the minimum length to be enforced by this `Validator`, or null if it has not been set.
    `javax.faces.el.ValueBinding` | `getValueBinding(String name)` Deprecated.
    `javax.el.ValueExpression` | `getValueExpression(String name)` Return the `ValueExpression` used to calculate the value for the specified attribute name, if any.
    `protected boolean` | `isMaximumSet()`
    `protected boolean` | `isMinimumSet()`
    `boolean` | `isTransient()`
    `void` | `restoreState(javax.faces.context.FacesContext context, Object state)`
    `Object` | `saveState(javax.faces.context.FacesContext context)`
    `void` | `setHintExact(String hintExact)` Custom hint exact message.
    `void` | `setHintMaximum(String hintMaximum)` Custom hint maximum message.
    `void` | `setHintMinimum(String hintMinimum)` Custom hint minimum message.
    `void` | `setHintNotInRange(String hintNotInRange)` Custom hint notInRange message.
    `void` | `setMaximum(int maximum)` Set the maximum length to be enforced by this `Validator`.
    `void` | `setMessageDetailExact(String exactMessageDetail)` Custom error message to be used, for creating detail part of the `FacesMessage`, for cases where the maximum and minimum lengths are the same, and the input length does not match.
    `void` | `setMessageDetailMaximum(String maximumMessageDetail)` Custom error message to be used, for creating detail part of the `FacesMessage`, when input length exceeds the maximum length set.
    `void` | `setMessageDetailMinimum(String minimumMessageDetail)` Custom error message to be used, for creating detail part of the `FacesMessage`, when input length is less the set `minimum` length.
    `void` | `setMessageDetailNotInRange(String notInRangeMessageDetail)` Custom error message to be used, for creating detail part of the `FacesMessage`, when input length is not with in the range, when `minimum` and `maximum` is set.
    `void` | `setMinimum(int minimum)` Set the minimum length to be enforced by this `Validator`.
    `void` | `setTransient(boolean transientValue)`
    `void` | `setValueBinding(String name, javax.faces.el.ValueBinding binding)` Deprecated.
    `void` | `setValueExpression(String name, javax.el.ValueExpression expression)` Set the `ValueExpression` used to calculate the value for the specified attribute if any.
    `void` | `validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)`

    - ### Methods inherited from class javax.faces.validator.LengthValidator

      `equals`

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

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

- - ### Field Detail

    - #### VALIDATOR_ID

          public static final String VALIDATOR_ID

      See Also:
        Constant Field Values

    - #### MAXIMUM_MESSAGE_ID

          public static final String MAXIMUM_MESSAGE_ID

      The message identifier of the `FacesMessage` to be created if the maximum length check fails. The message format string for this message may optionally include `{0}`, `{1}` and `{3}` placeholders, which will be replaced by user input, component label and configured maximum length.

      See Also:
        Constant Field Values

    - #### MINIMUM_MESSAGE_ID

          public static final String MINIMUM_MESSAGE_ID

      The message identifier of the `FacesMessage` to be created if the minimum length check fails. The message format string for this message may optionally include `{0}`, `{1}` and `{2}` placeholders, which will be replaced by user input, component label and configured minimum length.

      See Also:
        Constant Field Values

    - #### NOT_IN_RANGE_MESSAGE_ID

          public static final String NOT_IN_RANGE_MESSAGE_ID

      The message identifier of the `FacesMessage` to be created if the maximum or minimum length check fails, and both the maximum and minimum lengths for this validator have been set. The message format string for this message may optionally include `{0}`, `{1}`, `{2}` and `{3}` placeholders, which will be replaced by user input, component label, configured minimum length and configured maximum length.

      See Also:
        Constant Field Values

    - #### EXACT_MESSAGE_ID

          public static final String EXACT_MESSAGE_ID

      The message identifier of the `FacesMessage` to be created if the maximum and minimum lengths are the same, and the length check fails, and both the maximum and minimum values for this validator have been set. The message format string for this message may optionally include `{0}`, `{1}`, `{2}` placeholders, which will be replaced by user input, component label, configured minimum/maximum length.

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### LengthValidator

          public LengthValidator()

      Construct a `Validator` with no preconfigured limits.

    - #### LengthValidator

          public LengthValidator(int maximum)

      Construct a `Validator` with the specified preconfigured limit.
      Parameters:
        `maximum` - Maximum length to allow

    - #### LengthValidator

          public LengthValidator(int maximum,
                         int minimum)

      Construct a `Validator` with the specified preconfigured limits.
      Parameters:
        `maximum` - Maximum length to allow
        `minimum` - Minimum length to allow

  - ### Method Detail

    - #### getMaximum

          public int getMaximum()

      Return the maximum length to be enforced by this `Validator` or null if it has not been set.
      Overrides:
        `getMaximum` in class `javax.faces.validator.LengthValidator`

    - #### setMaximum

          public void setMaximum(int maximum)

      Set the maximum length to be enforced by this `Validator`.
      Overrides:
        `setMaximum` in class `javax.faces.validator.LengthValidator`
      Parameters:
        `maximum` - The new maximum length

    - #### getMinimum

          public int getMinimum()

      Return the minimum length to be enforced by this `Validator`, or null if it has not been set.
      Overrides:
        `getMinimum` in class `javax.faces.validator.LengthValidator`

    - #### setMinimum

          public void setMinimum(int minimum)

      Set the minimum length to be enforced by this `Validator`.
      Overrides:
        `setMinimum` in class `javax.faces.validator.LengthValidator`
      Parameters:
        `minimum` - The new minimum length

    - #### setMessageDetailMaximum

          public void setMessageDetailMaximum(String maximumMessageDetail)

      Custom error message to be used, for creating detail part of the `FacesMessage`, when input length exceeds the maximum length set.

      Overrides detail message identified by message id `MAXIMUM_MESSAGE_ID`
      Parameters:
        `maximumMessageDetail` - Custom error message.

    - #### getMessageDetailMaximum

          public String getMessageDetailMaximum()

      Return custom detail error message that was set for creating `FacesMessage`, for cases where input length exceeds the `maximum` length set.

      Returns:
        Custom error message.
      See Also:
        `setMessageDetailMaximum(String)`

    - #### setMessageDetailMinimum

          public void setMessageDetailMinimum(String minimumMessageDetail)

      Custom error message to be used, for creating detail part of the `FacesMessage`, when input length is less the set `minimum` length.

      Overrides detail message identified by message id `MINIMUM_MESSAGE_ID`
      Parameters:
        `minimumMessageDetail` - Custom error message.

    - #### getMessageDetailMinimum

          public String getMessageDetailMinimum()

      Return custom detail error message that was set for creating `FacesMessage`, for cases where, input length is less than the `minimum` length set.

      Returns:
        Custom error message.
      See Also:
        `setMessageDetailMinimum(String)`

    - #### setMessageDetailNotInRange

          public void setMessageDetailNotInRange(String notInRangeMessageDetail)

      Custom error message to be used, for creating detail part of the `FacesMessage`, when input length is not with in the range, when `minimum` and `maximum` is set.

      Overrides detail message identified by message id `NOT_IN_RANGE_MESSAGE_ID`
      Parameters:
        `notInRangeMessageDetail` - Custom error message.

    - #### getMessageDetailNotInRange

          public String getMessageDetailNotInRange()

      Return custom detail error message that was set for creating `FacesMessage`, for cases where, input length exceeds the `maximum` length and is less than the `minimum` length set.

      Returns:
        Custom error message.
      See Also:
        `setMessageDetailNotInRange(String)`

    - #### setMessageDetailExact

          public void setMessageDetailExact(String exactMessageDetail)

      Custom error message to be used, for creating detail part of the `FacesMessage`, for cases where the maximum and minimum lengths are the same, and the input length does not match. Overrides detail message identified by message id `EXACT_MESSAGE_ID`

      Parameters:
        `exactMessageDetail` - Custom error message.

    - #### getMessageDetailExact

          public String getMessageDetailExact()

      Return custom detail error message that was set for creating `FacesMessage`, for cases where the maximum and minimum lengths are the same, and the input length does not match.

      Returns:
        Custom error message.
      See Also:
        `setMessageDetailExact(String)`

    - #### setHintMaximum

          public void setHintMaximum(String hintMaximum)

      Custom hint maximum message.

      Overrides default hint message
      Parameters:
        `hintMaximum` - Custom hint message.

    - #### getHintMaximum

          public String getHintMaximum()

      Return custom hint maximum message.

      Returns:
        Custom hint message.
      See Also:
        `setHintMaximum(String)`

    - #### setHintMinimum

          public void setHintMinimum(String hintMinimum)

      Custom hint minimum message.

      Overrides default hint message
      Parameters:
        `hintMinimum` - Custom hint message.

    - #### getHintMinimum

          public String getHintMinimum()

      Return custom hint minimum message.

      Returns:
        Custom hint message.
      See Also:
        `setHintMinimum(String)`

    - #### setHintNotInRange

          public void setHintNotInRange(String hintNotInRange)

      Custom hint notInRange message.

      Overrides default hint message
      Parameters:
        `hintNotInRange` - Custom hint message.

    - #### getHintNotInRange

          public String getHintNotInRange()

      Return custom hint notInRange message.

      Returns:
        Custom hint message.
      See Also:
        `setHintNotInRange(java.lang.String)`

    - #### setHintExact

          public void setHintExact(String hintExact)

      Custom hint exact message.

      Overrides default hint message
      Parameters:
        `hintExact` - Custom hint message.

    - #### getHintExact

          public String getHintExact()

      Return custom hint exact message.

      Returns:
        Custom hint message.
      See Also:
        `setHintExact(java.lang.String)`

    - #### validate

          public void validate(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component,
                      Object value)
                        throws javax.faces.validator.ValidatorException

      Specified by:
        `validate` in interface `javax.faces.validator.Validator`
      Overrides:
        `validate` in class `javax.faces.validator.LengthValidator`
      Throws:
        `javax.faces.validator.ValidatorException`

    - #### saveState

          public Object saveState(javax.faces.context.FacesContext context)

      Specified by:
        `saveState` in interface `javax.faces.component.StateHolder`
      Overrides:
        `saveState` in class `javax.faces.validator.LengthValidator`

    - #### restoreState

          public void restoreState(javax.faces.context.FacesContext context,
                          Object state)

      Specified by:
        `restoreState` in interface `javax.faces.component.StateHolder`
      Overrides:
        `restoreState` in class `javax.faces.validator.LengthValidator`

    - #### setValueExpression

          public void setValueExpression(String name,
                                javax.el.ValueExpression expression)

      Set the `ValueExpression` used to calculate the value for the specified attribute if any.

      Parameters:
        `name` - Name of the attribute for which to set a `ValueExpression`
        `expression` - The `ValueExpression` to set, or `null` to remove any currently set `ValueExpression`
      Throws:
        `NullPointerException` - if `name` is `null`
        `IllegalArgumentException` - if `name` is not a valid attribute of this converter

    - #### getValueExpression

          public javax.el.ValueExpression getValueExpression(String name)

      Return the `ValueExpression` used to calculate the value for the specified attribute name, if any.

      Parameters:
        `name` - Name of the attribute or property for which to retrieve a `ValueExpression`
      Throws:
        `NullPointerException` - if `name` is `null`
        `IllegalArgumentException` - if `name` is not a valid attribute of this converter

    - #### setValueBinding

          public void setValueBinding(String name,
                             javax.faces.el.ValueBinding binding)

      Deprecated.

      Set the `ValueBinding` used to calculate the value for the specified attribute if any.

      Parameters:
        `name` - Name of the attribute for which to set a `ValueBinding`
        `binding` - The `ValueBinding` to set, or `null` to remove any currently set `ValueBinding`
      Throws:
        `NullPointerException` - if `name` is `null`
        `IllegalArgumentException` - if `name` is not a valid attribute of this validator

    - #### getValueBinding

          public javax.faces.el.ValueBinding getValueBinding(String name)

      Deprecated.

      Return the `ValueBinding` used to calculate the value for the specified attribute name, if any.

      Parameters:
        `name` - Name of the attribute or property for which to retrieve a `ValueBinding`
      Throws:
        `NullPointerException` - if `name` is `null`
        `IllegalArgumentException` - if `name` is not a valid attribute of this validator

    - #### isTransient

          public boolean isTransient()

      Specified by:
        `isTransient` in interface `javax.faces.component.StateHolder`
      Overrides:
        `isTransient` in class `javax.faces.validator.LengthValidator`

    - #### setTransient

          public void setTransient(boolean transientValue)

      Specified by:
        `setTransient` in interface `javax.faces.component.StateHolder`
      Overrides:
        `setTransient` in class `javax.faces.validator.LengthValidator`

    - #### isMaximumSet

          protected boolean isMaximumSet()

    - #### isMinimumSet

          protected boolean isMinimumSet()

Copyright © 2001-2016 The Apache Software Foundation. All Rights Reserved.