Package org.apache.commons.validator
Class Form
- java.lang.Object
-
- org.apache.commons.validator.Form
-
- All Implemented Interfaces:
java.io.Serializable
public class Form extends java.lang.Object implements java.io.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.
- Version:
- $Revision: 1739361 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.collections.FastHashMap
hFields
Deprecated.Subclasses should use getFieldMap() instead.protected java.lang.String
inherit
The name/key of the form which this form extends from.protected java.util.List<Field>
lFields
List ofField
s.protected java.lang.String
name
The name/key the set of validation rules is stored under.
-
Constructor Summary
Constructors Constructor Description Form()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addField(Field f)
Add aField
to theForm
.boolean
containsField(java.lang.String fieldName)
Returns true if this Form contains a Field with the given name.java.lang.String
getExtends()
Gets the name/key of the parent set of validation rules.Field
getField(java.lang.String fieldName)
Returns the Field with the given name or null if this Form has no such field.protected java.util.Map<java.lang.String,Field>
getFieldMap()
Returns a Map of String field keys to Field objects.java.util.List<Field>
getFields()
AList
ofField
s is returned as an unmodifiableList
.java.lang.String
getName()
Gets the name/key of the set of validation rules.boolean
isExtending()
Get extends flag.boolean
isProcessed()
Whether or not the thisForm
was processed for replacing variables in strings with their values.protected void
merge(Form depends)
Merges the given form into this one.protected void
process(java.util.Map<java.lang.String,java.lang.String> globalConstants, java.util.Map<java.lang.String,java.lang.String> constants, java.util.Map<java.lang.String,Form> forms)
Processes all of theForm
'sField
s.void
setExtends(java.lang.String inherit)
Sets the name/key of the parent set of validation rules.void
setName(java.lang.String name)
Sets the name/key of the set of validation rules.java.lang.String
toString()
Returns a string representation of the object.
-
-
-
Field Detail
-
name
protected java.lang.String name
The name/key the set of validation rules is stored under.
-
lFields
protected java.util.List<Field> lFields
List ofField
s. Used to maintain the order they were added in although individualField
s can be retrieved usingMap
ofField
s.
-
hFields
@Deprecated protected org.apache.commons.collections.FastHashMap hFields
Deprecated.Subclasses should use getFieldMap() instead.Map ofField
s keyed on their property value.
-
inherit
protected java.lang.String inherit
The name/key of the form which this form extends from.- Since:
- Validator 1.2.0
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name/key of the set of validation rules.- Returns:
- The name value
-
setName
public void setName(java.lang.String name)
Sets the name/key of the set of validation rules.- Parameters:
name
- The new name value
-
addField
public void addField(Field f)
Add aField
to theForm
.- Parameters:
f
- The field
-
getFields
public java.util.List<Field> getFields()
AList
ofField
s is returned as an unmodifiableList
.- Returns:
- The fields value
-
getField
public Field getField(java.lang.String fieldName)
Returns the Field with the given name or null if this Form has no such field.- Parameters:
fieldName
- The field name- Returns:
- The field value
- Since:
- Validator 1.1
-
containsField
public boolean containsField(java.lang.String fieldName)
Returns true if this Form contains a Field with the given name.- Parameters:
fieldName
- The field name- Returns:
- True if this form contains the field by the given name
- Since:
- Validator 1.1
-
merge
protected void merge(Form depends)
Merges the given form into this one. For any field independs
not present in this form, include it.depends
has precedence in the way the fields are ordered.- Parameters:
depends
- the form we want to merge- Since:
- Validator 1.2.0
-
process
protected void process(java.util.Map<java.lang.String,java.lang.String> globalConstants, java.util.Map<java.lang.String,java.lang.String> constants, java.util.Map<java.lang.String,Form> forms)
Processes all of theForm
'sField
s.- Parameters:
globalConstants
- A map of global constantsconstants
- Local constantsforms
- Map of forms- Since:
- Validator 1.2.0
-
toString
public java.lang.String toString()
Returns a string representation of the object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- string representation
-
isProcessed
public boolean isProcessed()
Whether or not the thisForm
was processed for replacing variables in strings with their values.- Returns:
- The processed value
- Since:
- Validator 1.2.0
-
getExtends
public java.lang.String getExtends()
Gets the name/key of the parent set of validation rules.- Returns:
- The extends value
- Since:
- Validator 1.2.0
-
setExtends
public void setExtends(java.lang.String inherit)
Sets the name/key of the parent set of validation rules.- Parameters:
inherit
- The new extends value- Since:
- Validator 1.2.0
-
isExtending
public boolean isExtending()
Get extends flag.- Returns:
- The extending value
- Since:
- Validator 1.2.0
-
getFieldMap
protected java.util.Map<java.lang.String,Field> getFieldMap()
Returns a Map of String field keys to Field objects.- Returns:
- The fieldMap value
- Since:
- Validator 1.2.0
-
-