org.formproc.validation
Class Validator

java.lang.Object
  |
  +--org.formproc.validation.Validator
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
PassValidator, REValidator, RuleValidator, ScriptValidator, UsernameValidator, ValidatorGroup

public abstract class Validator
extends java.lang.Object
implements java.lang.Cloneable

Base class for all validators. Validators must implement the validate() method to provide validation logic.

Author:
Anthony Eden

Field Summary
protected  FormManager formManager
           
protected  MessageProvider messageProvider
           
protected  java.util.Map properties
           
 
Constructor Summary
Validator()
          Construct a new Validator.
 
Method Summary
 java.lang.Object clone()
          Clone the validator.
 void configure(com.anthonyeden.lib.config.Configuration configuration)
          Configure the validator using the given configuration object.
 void configureInternal(com.anthonyeden.lib.config.Configuration configuration)
          Implementations can override this method to configure themselves.
 java.lang.String getErrorMessage()
          Return the validator error message using the default Locale.
 java.lang.String getErrorMessage(java.util.Locale locale)
          Get the validator error message for the given locale.
 void setFormManager(FormManager formManager)
          Set the FormManager.
 void setProperties(java.util.Map properties)
          Set the global properties which are shared between all validators of a particular type.
abstract  ValidationResult validate(FormElement[] formElements, FormData[] formData, java.util.Locale locale)
          Validate the given FormData array.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formManager

protected FormManager formManager

messageProvider

protected MessageProvider messageProvider

properties

protected java.util.Map properties
Constructor Detail

Validator

public Validator()
Construct a new Validator.

Method Detail

configure

public final void configure(com.anthonyeden.lib.config.Configuration configuration)
                     throws java.lang.Exception
Configure the validator using the given configuration object. Subclasses cannot override this method. Instead they should override the configureInternal() method.

Parameters:
configuration - The Configuration object
Throws:
java.lang.Exception

configureInternal

public void configureInternal(com.anthonyeden.lib.config.Configuration configuration)
                       throws java.lang.Exception
Implementations can override this method to configure themselves. This method is called after the configure() method finishes.

Parameters:
configuration - The Configuration object
Throws:
java.lang.Exception

setFormManager

public void setFormManager(FormManager formManager)
Set the FormManager.

Parameters:
formManager - The FormManager

setProperties

public void setProperties(java.util.Map properties)
Set the global properties which are shared between all validators of a particular type.

Parameters:
properties - The properties Map

getErrorMessage

public java.lang.String getErrorMessage()
Return the validator error message using the default Locale.

Returns:
The error message

getErrorMessage

public java.lang.String getErrorMessage(java.util.Locale locale)
Get the validator error message for the given locale. If no error message is specified in the configuration then this method returns null.

Parameters:
locale - The locale
Returns:
The error message

clone

public java.lang.Object clone()
Clone the validator.

Overrides:
clone in class java.lang.Object
Returns:
The cloned validator

validate

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

Parameters:
formElements - An array of FormElement objects
formData - An array of FormData objects
locale - The Locale
Returns:
The validation result
Throws:
java.lang.Exception


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