org.apache.commons.validator

Class Form

Implemented Interfaces:
Serializable

public class Form
extends java.lang.Object
implements Serializable

This contains a set of validation rules for a form/JavaBean. The information is contained in a list of Field objects. Instances of this class are configured with a <form> xml element.

The use of FastHashMap is deprecated and will be replaced in a future release.

Field Summary

protected FastHashMap
hFields
Map of Fields keyed on their property value.
protected List
lFields
List of Fields.
protected String
name
The name/key the set of validation rules is stored under.

Method Summary

void
addField(Field f)
Add a Field to the Form.
boolean
containsField(String fieldName)
Returns true if this Form contains a Field with the given name.
Field
getField(String fieldName)
Returns the Field with the given name or null if this Form has no such field.
Map
getFieldMap()
Deprecated. Use containsField(String) and getField(String) instead.
List
getFields()
A List of Fields is returned as an unmodifiable List.
String
getName()
Gets the name/key of the set of validation rules.
void
process(Map globalConstants, Map constants)
Deprecated. This method is called by the framework.
void
setName(String name)
Sets the name/key of the set of validation rules.
String
toString()
Returns a string representation of the object.
(package private) ValidatorResults
validate(Map params, Map actions, int page)
Validate all Fields in this Form on the given page and below.

Field Details

hFields

protected FastHashMap hFields
Map of Fields keyed on their property value.


lFields

protected List lFields
List of Fields. Used to maintain the order they were added in although individual Fields can be retrieved using Map of Fields.


name

protected String name
The name/key the set of validation rules is stored under.

Method Details

addField

public void addField(Field f)
Add a Field to the Form.


containsField

public boolean containsField(String fieldName)
Returns true if this Form contains a Field with the given name.

Since:
Validator 1.1


getField

public Field getField(String fieldName)
Returns the Field with the given name or null if this Form has no such field.

Since:
Validator 1.1


getFieldMap

public Map getFieldMap()

Deprecated. Use containsField(String) and getField(String) instead.

The Fields are returned as an unmodifiable Map.


getFields

public List getFields()
A List of Fields is returned as an unmodifiable List.


getName

public String getName()
Gets the name/key of the set of validation rules.


process

public void process(Map globalConstants,
                    Map constants)

Deprecated. This method is called by the framework. It will be made protected in a future release. TODO

Processes all of the Form's Fields.


setName

public void setName(String name)
Sets the name/key of the set of validation rules.


toString

public String toString()
Returns a string representation of the object.


validate

(package private)  ValidatorResults validate(Map params,
                                             Map actions,
                                             int page)
            throws ValidatorException
Validate all Fields in this Form on the given page and below.

Parameters:
params - A Map of parameter class names to parameter values to pass into validation methods.
actions - A Map of validator names to ValidatorAction objects.
page - Fields on pages higher than this will not be validated.

Returns:
A ValidatorResults object containing all validation messages.

Throws:
ValidatorException -


Copyright (c) 2001-2004 Apache Software Foundation