org.formproc.validation
Class REValidator

java.lang.Object
  |
  +--org.formproc.validation.Validator
        |
        +--org.formproc.validation.REValidator
All Implemented Interfaces:
java.lang.Cloneable

public class REValidator
extends Validator

An implementation of the Validator interface which validates FormElements based on a Perl 5 regular expression.

Author:
Anthony Eden

Field Summary
 
Fields inherited from class org.formproc.validation.Validator
formManager, messageProvider, properties
 
Constructor Summary
REValidator()
          Construct a new REFormValidator.
REValidator(java.lang.String pattern)
          Construct a new REValidator with the given pattern.
 
Method Summary
 void configureInternal(com.anthonyeden.lib.config.Configuration configuration)
          Configure the validator using the given JDOM element.
 org.apache.oro.text.regex.Pattern getPattern()
          Get the Pattern used for matching.
protected  java.lang.String getPatternString()
          Get the current pattern as a String.
 void setPattern(org.apache.oro.text.regex.Pattern pattern)
          Set the regular expression pattern.
 void setPattern(java.lang.String pattern)
          Set the regular expression pattern to the given String.
 ValidationResult validate(FormElement[] formElements, FormData[] formData, java.util.Locale locale)
          Validate the given FormData array.
 
Methods inherited from class org.formproc.validation.Validator
clone, configure, getErrorMessage, getErrorMessage, setFormManager, setProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

REValidator

public REValidator()
Construct a new REFormValidator. This constructor will initialize the Perl5Compiler and matcher.


REValidator

public REValidator(java.lang.String pattern)
            throws org.apache.oro.text.regex.MalformedPatternException
Construct a new REValidator with the given pattern.

Parameters:
pattern - The pattern
Throws:
org.apache.oro.text.regex.MalformedPatternException
Method Detail

getPattern

public org.apache.oro.text.regex.Pattern getPattern()
Get the Pattern used for matching.

Returns:
The Pattern
See Also:
Pattern

setPattern

public void setPattern(java.lang.String pattern)
                throws org.apache.oro.text.regex.MalformedPatternException
Set the regular expression pattern to the given String.

Parameters:
pattern - The pattern String
Throws:
org.apache.oro.text.regex.MalformedPatternException

setPattern

public void setPattern(org.apache.oro.text.regex.Pattern pattern)
Set the regular expression pattern.

Parameters:
pattern - The Pattern

configureInternal

public void configureInternal(com.anthonyeden.lib.config.Configuration configuration)
                       throws java.lang.Exception
Configure the validator using the given JDOM element.

Overrides:
configureInternal in class Validator
Parameters:
configuration - The Configuration object
Throws:
java.lang.Exception

validate

public ValidationResult validate(FormElement[] formElements,
                                 FormData[] formData,
                                 java.util.Locale locale)
                          throws java.lang.Exception
Validate the given FormData array.

Specified by:
validate in class Validator
Parameters:
formElements - An array of FormElement objects
formData - An array of FormData objects
locale - The Locale
Returns:
The validation result
Throws:
java.lang.Exception

getPatternString

protected java.lang.String getPatternString()
Get the current pattern as a String. This method may return a null value.

Returns:
The pattern String or null


Copyright (c) 2001-2003 Anthony Eden. All Rights Reserved.