oracle.adf.view.faces.validator
Class ByteLengthValidator

java.lang.Object
  |
  +--oracle.adf.view.faces.validator.ByteLengthValidator
All Implemented Interfaces:
java.util.EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator

public class ByteLengthValidator
extends java.lang.Object
implements javax.faces.component.StateHolder, javax.faces.validator.Validator

ByteLengthValidator is a Validator that checks the value of the corresponding component for its byte length for the set character encoding. The following algorithm is implemented:


Field Summary
static java.lang.String MAXIMUM_FAILED_AT_INDEX_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the maximum byte length check fails indicating the index where the failure occurs.
static java.lang.String MAXIMUM_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the maximum byte length check fails.
static java.lang.String TYPE_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the current value of this component is not of the correct type.
static java.lang.String UNSUPPORTED_ENCODING_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the the encoding is not supported.
static java.lang.String VALIDATOR_ID
          Standard validator id for this validator.
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
ByteLengthValidator()
          Construct a Validator with iso-8859-1 as the encoding and zero as the maximum bytes allowed.
ByteLengthValidator(int maximumBytes, java.lang.String encoding)
          Construct a Validator with the specified preconfigured values.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compares this ByteLengthValidator with the specified Object for equality.
 java.lang.String getEncoding()
          Return the character encoding set for this Validator or iso-8859-1 if it has not been set.
 int getMaximumBytes()
          Return the maximum bytes to be enforced by this Validator or zero if it has not been set.
 int hashCode()
          Returns the hash code for this Validator.
 boolean isTransient()
           
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setEncoding(java.lang.String encoding)
          Set the character encoding for this Validator.
 void setMaximumBytes(int maximumBytes)
          Set the maximum bytes to be enforced by this Validator.
 void setTransient(boolean transientValue)
           
 void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Validates unless it is too long, in which case throws ValidatorException.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_MESSAGE_ID

public static final java.lang.String MAXIMUM_MESSAGE_ID

The message identifier of the FacesMessage to be created if the maximum byte length check fails. The message format string for this message may optionally include a {0} placeholder, which will be replaced by the maximum bytes set.

See Also:
Constant Field Values

MAXIMUM_FAILED_AT_INDEX_MESSAGE_ID

public static final java.lang.String MAXIMUM_FAILED_AT_INDEX_MESSAGE_ID

The message identifier of the FacesMessage to be created if the maximum byte length check fails indicating the index where the failure occurs. The message format string for this message may optionally include a {0} placeholder, which will be replaced by the maximum byte length set and {1} with index at which the validation fails.

See Also:
Constant Field Values

UNSUPPORTED_ENCODING_MESSAGE_ID

public static final java.lang.String UNSUPPORTED_ENCODING_MESSAGE_ID

The message identifier of the FacesMessage to be created if the the encoding is not supported. The message format string for this message may optionally include a {0} placeholder, which will be replaced by the encoding that was set.

See Also:
Constant Field Values

TYPE_MESSAGE_ID

public static final java.lang.String TYPE_MESSAGE_ID

The message identifier of the FacesMessage to be created if the current value of this component is not of the correct type.

See Also:
Constant Field Values

VALIDATOR_ID

public static final java.lang.String VALIDATOR_ID

Standard validator id for this validator.

See Also:
Constant Field Values
Constructor Detail

ByteLengthValidator

public ByteLengthValidator()

Construct a Validator with iso-8859-1 as the encoding and zero as the maximum bytes allowed.


ByteLengthValidator

public ByteLengthValidator(int maximumBytes,
                           java.lang.String encoding)

Construct a Validator with the specified preconfigured values.

Parameters:
maximumBytes - the maximum number of bytes allowed.
encoding - the Java character set encoding. This must be an encoding supported by Java.
Method Detail

setEncoding

public void setEncoding(java.lang.String encoding)

Set the character encoding for this Validator.

Parameters:
encoding - The character encoding.

getEncoding

public java.lang.String getEncoding()

Return the character encoding set for this Validator or iso-8859-1 if it has not been set.


setMaximumBytes

public void setMaximumBytes(int maximumBytes)

Set the maximum bytes to be enforced by this Validator.

Parameters:
maximumBytes - The new maximum value

getMaximumBytes

public int getMaximumBytes()

Return the maximum bytes to be enforced by this Validator or zero if it has not been set.


validate

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

Validates unless it is too long, in which case throws ValidatorException.

Specified by:
validate in interface javax.faces.validator.Validator
Throws:
javax.faces.validator.ValidatorException - if validation fails
java.lang.NullPointerException - if context or component is null

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder

isTransient

public boolean isTransient()
Specified by:
isTransient in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean transientValue)
Specified by:
setTransient in interface javax.faces.component.StateHolder

equals

public boolean equals(java.lang.Object object)

Compares this ByteLengthValidator with the specified Object for equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - Object to which this ByteLengthValidator is to be compared.
Returns:
true if and only if the specified Object is a ByteLengthValidator and if the values encoding, maximumBytes and transient are equal.

hashCode

public int hashCode()

Returns the hash code for this Validator.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.


Copyright © 2003-2004 Oracle Corporation. All Rights Reserved.