|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
org.apache.myfaces.trinidad.validator.ByteLengthValidator
public class ByteLengthValidator
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:
null, exit immediately.encoding and maximum property has been configured on this Validator, check the component value byte length against the maximum. If the component value byte length is greater than this specified maximum, throw a ValidatorException containing a MAXIMUM_MESSAGE_ID message.maximum property has been configured on this Validator, check the component value against this limit defaulting the encoding to be iso-8859-1. If the component value length is greater than the specified maximum, throw a ValidatorException containing a MAXIMUM_MESSAGE_ID message.encoding property has been configured on this Validator, and if it is not a valid Java encoding, then throws a IllegalCharsetNameExceptionmaximumMessageDetail is set, it is used for constructing faces message, when validation fails. The message can contain placeholders which will be replaced as specified in MAXIMUM_MESSAGE_IDsetMessageDetailMaximum(String)| Field Summary | |
|---|---|
static java.lang.String |
MAXIMUM_MESSAGE_IDThe message identifier of the FacesMessage to be created if the maximum byte length check fails. |
static java.lang.String |
VALIDATOR_IDStandard 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 maximum, 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. |
java.lang.String |
getHintMaximum()Return custom hint message. |
protected javax.faces.application.FacesMessage |
getLengthValidationFailureMessage(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String value)The FacesMessage to be returned if byte length validation fails. |
int |
getMaximum()Return the maximum bytes to be enforced by this Validator or zero if it has not been set. |
java.lang.String |
getMessageDetailMaximum()Return custom detail error message that was set for creating FacesMessage, for values that exceeds the maximum byte length. |
javax.faces.el.ValueBinding |
getValueBinding(java.lang.String name)Deprecated. |
javax.el.ValueExpression |
getValueExpression(java.lang.String name)Return the ValueExpression used to calculate the value for the specified attribute name, if any. |
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 |
setHintMaximum(java.lang.String hintMaximum)Custom hint message. |
void |
setMaximum(int maximum)Set the maximum bytes to be enforced by this Validator. |
void |
setMessageDetailMaximum(java.lang.String maximumMessageDetail)Custom error message to be used, for creating detail part of the FacesMessage, when users input exceeds the maximum byte length. |
void |
setTransient(boolean transientValue) |
void |
setValueBinding(java.lang.String name, javax.faces.el.ValueBinding binding)Deprecated. |
void |
setValueExpression(java.lang.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, 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 |
|---|
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 {0}, {1} and {2} placeholders, which will be replaced by input value, label associated with the component and the maximum bytes respectively.
public static final java.lang.String VALIDATOR_ID
Standard validator id for this validator.
| Constructor Detail |
|---|
public ByteLengthValidator()
Construct a Validator with iso-8859-1 as the encoding and zero as the maximum bytes allowed.
public ByteLengthValidator(int maximum,
java.lang.String encoding)
Construct a Validator with the specified preconfigured values.
maximum - the maximum number of bytes allowed.encoding - the Java character set encoding. This must be an encoding supported by Java.| Method Detail |
|---|
public void setEncoding(java.lang.String encoding)
Set the character encoding for this Validator.
encoding - The character encoding.public java.lang.String getEncoding()
Return the character encoding set for this Validator or iso-8859-1 if it has not been set.
public void setMaximum(int maximum)
Set the maximum bytes to be enforced by this Validator.
maximum - The new maximum valuepublic int getMaximum()
Return the maximum bytes to be enforced by this Validator or zero if it has not been set.
public void setMessageDetailMaximum(java.lang.String maximumMessageDetail)
Custom error message to be used, for creating detail part of the FacesMessage, when users input exceeds the maximum byte length.
MAXIMUM_MESSAGE_IDmaximumMessageDetail - Custom error message.public java.lang.String getMessageDetailMaximum()
Return custom detail error message that was set for creating FacesMessage, for values that exceeds the maximum byte length.
setMessageDetailMaximum(String)public void setHintMaximum(java.lang.String hintMaximum)
Custom hint message.
Overrides default hint messagehintMaximum - Custom hint message.public java.lang.String getHintMaximum()
Return custom hint message.
setHintMaximum(String)
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.
validate in interface javax.faces.validator.Validatorjavax.faces.validator.ValidatorException - if validation failsjava.lang.NullPointerException - if contextjava.nio.charset.IllegalCharsetNameException - if encoding isjava.lang.IllegalArgumentException - if value is not of type String unsupported or component is nullpublic java.lang.Object saveState(javax.faces.context.FacesContext context)
saveState in interface javax.faces.component.StateHolder
public void restoreState(javax.faces.context.FacesContext context,
java.lang.Object state)
restoreState in interface javax.faces.component.StateHolderpublic boolean isTransient()
isTransient in interface javax.faces.component.StateHolderpublic void setTransient(boolean transientValue)
setTransient in interface javax.faces.component.StateHolder
public void setValueExpression(java.lang.String name,
javax.el.ValueExpression expression)
Set the ValueExpression used to calculate the value for the specified attribute if any.
name - Name of the attribute for which to set a ValueExpressionexpression - The ValueExpression to set, or null to remove any currently set ValueExpressionjava.lang.NullPointerException - if name is nulljava.lang.IllegalArgumentException - if name is not a valid attribute of this converterpublic javax.el.ValueExpression getValueExpression(java.lang.String name)
Return the ValueExpression used to calculate the value for the specified attribute name, if any.
name - Name of the attribute or property for which to retrieve a ValueExpressionjava.lang.NullPointerException - if name is nulljava.lang.IllegalArgumentException - if name is not a valid attribute of this converter
public void setValueBinding(java.lang.String name,
javax.faces.el.ValueBinding binding)
Set the ValueBinding used to calculate the value for the specified attribute if any.
name - Name of the attribute for which to set a ValueBindingbinding - The ValueBinding to set, or null to remove any currently set ValueBindingjava.lang.NullPointerException - if name is nulljava.lang.IllegalArgumentException - if name is not a valid attribute of this validatorpublic javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
Return the ValueBinding used to calculate the value for the specified attribute name, if any.
name - Name of the attribute or property for which to retrieve a ValueBindingjava.lang.NullPointerException - if name is nulljava.lang.IllegalArgumentException - if name is not a valid attribute of this validatorpublic boolean equals(java.lang.Object object)
Compares this ByteLengthValidator with the specified Object for equality.
equals in class java.lang.Objectobject - Object to which this ByteLengthValidator is to be compared.public int hashCode()
Returns the hash code for this Validator.
hashCode in class java.lang.Object
protected javax.faces.application.FacesMessage getLengthValidationFailureMessage(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.String value)
FacesMessage to be returned if byte length validation fails.context - Faces contextvalue - The value entered / set by the user on the component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.