org.formproc.validation
Class ScriptValidator

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

public class ScriptValidator
extends Validator

A Validator which uses a BSF-supported script to validate the form data. Scripts are located by using the scriptRoot value as the base search path. The script root can either be a file or the classpath. In the case of the class path, the script must be located in the class path.

Author:
Anthony Eden

Field Summary
static java.lang.String DEFAULT_SCRIPT_ROOT_TYPE
          The default script root type ("file").
static java.lang.String SCRIPT_ROOT_TYPE_CLASSPATH
          The script root type "classpath".
static java.lang.String SCRIPT_ROOT_TYPE_FILE
          The script root type "file".
 
Fields inherited from class org.formproc.validation.Validator
formManager, messageProvider, properties
 
Constructor Summary
ScriptValidator()
          Construct a new ScriptValidator.
 
Method Summary
 void configureInternal(com.anthonyeden.lib.config.Configuration configuration)
          Configure the validator using the given JDOM element.
 java.io.File getScript()
          Get the script file.
 java.io.File getScriptRoot()
          Get the script root.
 java.lang.String getScriptRootType()
          Get the type for the script root.
 void setProperties(java.util.Map properties)
          Set the global properties which are shared between all validators of a particular type.
 void setScript(java.io.File script)
          Set the script file.
 void setScript(java.lang.String script)
          Set the script file.
 void setScriptRoot(java.io.File scriptRoot)
          Set the script root.
 void setScriptRoot(java.lang.String scriptRoot)
          Set the script root.
 void setScriptRootType(java.lang.String scriptRootType)
          Set the type for the script root.
 ValidationResult validate(FormElement[] formElements, FormData[] formData, java.util.Locale locale)
          Validate the given FormData.
 
Methods inherited from class org.formproc.validation.Validator
clone, configure, getErrorMessage, getErrorMessage, setFormManager
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCRIPT_ROOT_TYPE_FILE

public static final java.lang.String SCRIPT_ROOT_TYPE_FILE
The script root type "file".

See Also:
Constant Field Values

SCRIPT_ROOT_TYPE_CLASSPATH

public static final java.lang.String SCRIPT_ROOT_TYPE_CLASSPATH
The script root type "classpath".

See Also:
Constant Field Values

DEFAULT_SCRIPT_ROOT_TYPE

public static final java.lang.String DEFAULT_SCRIPT_ROOT_TYPE
The default script root type ("file").

See Also:
Constant Field Values
Constructor Detail

ScriptValidator

public ScriptValidator()
Construct a new ScriptValidator.

Method Detail

getScriptRoot

public java.io.File getScriptRoot()
Get the script root.

Returns:
The script root

setScriptRoot

public void setScriptRoot(java.io.File scriptRoot)
Set the script root.

Parameters:
scriptRoot - The new script root

setScriptRoot

public void setScriptRoot(java.lang.String scriptRoot)
Set the script root.

Parameters:
scriptRoot - The new script root path

getScriptRootType

public java.lang.String getScriptRootType()
Get the type for the script root. Current supported values are "file" and "classpath". If the type is "file" then the value of script root will assumed to be a file in the file system. If the type is "classpath", then the root is the current Java class path and the class path is used to find script files.

The default type is "file".

Returns:
The root type

setScriptRootType

public void setScriptRootType(java.lang.String scriptRootType)
Set the type for the script root. Current supported values are "file" and "classpath".

Parameters:
scriptRootType - The script root type, either "file" or "classpath"
See Also:
getScriptRootType()

getScript

public java.io.File getScript()
Get the script file.

Returns:
The script file

setScript

public void setScript(java.io.File script)
Set the script file.

Parameters:
script - The new script file

setScript

public void setScript(java.lang.String script)
Set the script file.

Parameters:
script - The new script file

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

setProperties

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

Overrides:
setProperties in class Validator
Parameters:
properties - The properties Map

validate

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

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


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