org.apache.myfaces.trinidad.validator
Class RegExpValidator

java.lang.Object
  extended by org.apache.myfaces.trinidad.validator.RegExpValidator
All Implemented Interfaces:
java.util.EventListener, javax.faces.component.StateHolder, javax.faces.validator.Validator

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

RegExpValidator is a Validator that checks the value of the corresponding component against specified pattern using Java regular expression syntax. The regular expression syntax accepted by the RegExpValidator class is same as mentioned in class Pattern in package java.util.regex. The following algorithm is implemented:

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/validator/RegExpValidator.java#0 $) $Date: 10-nov-2005.19:08:34 $
See Also:
setMessageDetailNoMatch(String)

Field Summary
static java.lang.String NO_MATCH_MESSAGE_ID
          The message identifier of the FacesMessage to be created if the match fails.
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
RegExpValidator()
          Construct a RegExpValidator with no preconfigured pattern.
RegExpValidator(java.lang.String pattern)
          Construct a RegExpValidator with preconfigured pattern.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compares this PatternValidator with the specified Object for equality.
 java.lang.String getHint()
          Return custom hint message.
 java.lang.String getMessageDetailNoMatch()
          Return custom detail error message that was set for creating faces message, for values that do not match the specified pattern.
 java.lang.String getPattern()
          Return the pattern value to be enforced by this Validator
 javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
          Return the ValueBinding 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 setHint(java.lang.String hintPattern)
          Custom hint message.
 void setMessageDetailNoMatch(java.lang.String noMatchMessageDetail)
          Custom error message to be used, for creating detail part of the FacesMessage, when value does not match the specified pattern.
 void setPattern(java.lang.String pattern)
          Set the pattern value to be enforced by this Validator
 void setTransient(boolean transientValue)
           
 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.
 void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_ID

public static final java.lang.String VALIDATOR_ID

Standard validator id for this validator.

See Also:
Constant Field Values

NO_MATCH_MESSAGE_ID

public static final java.lang.String NO_MATCH_MESSAGE_ID

The message identifier of the FacesMessage to be created if the match fails. The message format string for this message may optionally include a {0}, {1} and {4} placeholders, which will be replaced input value, label associated with the component and pattern respectively.

See Also:
Constant Field Values
Constructor Detail

RegExpValidator

public RegExpValidator()

Construct a RegExpValidator with no preconfigured pattern.


RegExpValidator

public RegExpValidator(java.lang.String pattern)

Construct a RegExpValidator with preconfigured pattern.

Method Detail

validate

public void validate(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component,
                     java.lang.Object value)
              throws javax.faces.validator.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 or pattern is null
java.lang.IllegalArgumentException - if value is not of type String

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

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

setValueBinding

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.

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:
java.lang.NullPointerException - if name is null
java.lang.IllegalArgumentException - if name is not a valid attribute of this validator

getValueBinding

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

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:
java.lang.NullPointerException - if name is null
java.lang.IllegalArgumentException - if name is not a valid attribute of this validator

equals

public boolean equals(java.lang.Object object)

Compares this PatternValidator with the specified Object for equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - Object to which this PatternValidator is to be compared.
Returns:
true if and only if the specified Object is a PatternValidator and if the values pattern 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.

setHint

public void setHint(java.lang.String hintPattern)

Custom hint message.

Overrides default hint message

Parameters:
hintPattern - Custom hint message.

getHint

public java.lang.String getHint()

Return custom hint message.

Returns:
Custom hint message.
See Also:
setHint(String)

setPattern

public void setPattern(java.lang.String pattern)

Set the pattern value to be enforced by this Validator

Parameters:
pattern - to be enforced.

getPattern

public java.lang.String getPattern()

Return the pattern value to be enforced by this Validator


setMessageDetailNoMatch

public void setMessageDetailNoMatch(java.lang.String noMatchMessageDetail)

Custom error message to be used, for creating detail part of the FacesMessage, when value does not match the specified pattern.

Overrides detail message identified by message id NO_MATCH_MESSAGE_ID

Parameters:
noMatchMessageDetail -

getMessageDetailNoMatch

public java.lang.String getMessageDetailNoMatch()

Return custom detail error message that was set for creating faces message, for values that do not match the specified pattern.

Returns:
Custom error message
See Also:
setMessageDetailNoMatch(String)


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