org.apache.commons.validator
Class Field

java.lang.Object
  extended byorg.apache.commons.validator.Field
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Field
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This contains the list of pluggable validators to run on a field and any message information and variables to perform the validations and generate error messages. Instances of this class are configured with a <field> xml element. The use of FastHashMap is deprecated and will be replaced in a future release.

See Also:
Form, Serialized Form

Field Summary
static java.lang.String ARG_DEFAULT
          Deprecated.  
protected  java.util.Map[] args
          Holds Maps of arguments.
protected  java.lang.String depends
          A comma separated list of validator's this field depends on.
protected  int fieldOrder
           
protected  org.apache.commons.collections.FastHashMap hArg0
          Deprecated. This variable is no longer used, use args instead.
protected  org.apache.commons.collections.FastHashMap hArg1
          Deprecated. This variable is no longer used, use args instead.
protected  org.apache.commons.collections.FastHashMap hArg2
          Deprecated. This variable is no longer used, use args instead.
protected  org.apache.commons.collections.FastHashMap hArg3
          Deprecated. This variable is no longer used, use args instead.
protected  org.apache.commons.collections.FastHashMap hDependencies
          Deprecated. This is no longer used.
protected  org.apache.commons.collections.FastHashMap hMsgs
           
protected  org.apache.commons.collections.FastHashMap hVars
           
protected  java.lang.String indexedListProperty
           
protected  java.lang.String indexedProperty
           
protected  java.lang.String key
           
protected  int page
           
protected  java.lang.String property
           
protected static java.lang.String TOKEN_END
           
static java.lang.String TOKEN_INDEXED
          This indicates an indexed property is being referenced.
protected static java.lang.String TOKEN_START
           
protected static java.lang.String TOKEN_VAR
           
 
Constructor Summary
Field()
           
 
Method Summary
 void addArg(Arg arg)
          Add an Arg to the replacement argument list.
 void addArg0(Arg arg)
          Deprecated. Use addArg(Arg) instead.
 void addArg1(Arg arg)
          Deprecated. Use addArg(Arg) instead.
 void addArg2(Arg arg)
          Deprecated. Use addArg(Arg) instead.
 void addArg3(Arg arg)
          Deprecated. Use addArg(Arg) instead.
 void addMsg(Msg msg)
          Add a Msg to the Field.
 void addVar(java.lang.String name, java.lang.String value, java.lang.String jsType)
          Add a Var, based on the values passed in, to the Field.
 void addVar(Var v)
          Add a Var to the Field.
 void addVarParam(java.lang.String name, java.lang.String value, java.lang.String jsType)
          Deprecated. Use addVar(String, String, String) instead.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 void generateKey()
          Generate correct key value.
 Arg getArg(int position)
          Gets the default Arg object at the given position.
 Arg getArg(java.lang.String key, int position)
          Gets the Arg object at the given position.
 Arg getArg0()
          Deprecated. Use getArg(0) instead.
 Arg getArg0(java.lang.String key)
          Deprecated. Use getArg(String, 0) instead.
 Arg getArg1()
          Deprecated. Use getArg(1) instead.
 Arg getArg1(java.lang.String key)
          Deprecated. Use getArg(String, 1) instead.
 Arg getArg2()
          Deprecated. Use getArg(2) instead.
 Arg getArg2(java.lang.String key)
          Deprecated. Use getArg(String, 2) instead.
 Arg getArg3()
          Deprecated. Use getArg(3) instead.
 Arg getArg3(java.lang.String key)
          Deprecated. Use getArg(String, 3) instead.
 Arg[] getArgs(java.lang.String key)
          Retrieves the Args for the given validator name.
 java.util.Collection getDependencies()
          Deprecated. Use getDependencyList() instead.
 java.util.List getDependencyList()
          Gets an unmodifiable List of the dependencies in the same order they were defined in parameter passed to the setDepends() method.
 java.lang.String getDepends()
          Gets the validation rules for this field as a comma separated list.
 int getFieldOrder()
          Gets the position of the Field in the validation list.
 java.lang.String getIndexedListProperty()
          Gets the indexed property name of the field.
 java.lang.String getIndexedProperty()
          Gets the indexed property name of the field.
 java.lang.String getKey()
          Gets a unique key based on the property and indexedProperty fields.
 java.lang.String getMsg(java.lang.String key)
          Retrieve a message value.
 int getPage()
          Gets the page value that the Field is associated with for validation.
 java.lang.String getProperty()
          Gets the property name of the field.
 Var getVar(java.lang.String mainKey)
          Retrieve a variable.
 java.util.Map getVars()
          The Field's variables are returned as an unmodifiable Map.
 java.lang.String getVarValue(java.lang.String mainKey)
          Retrieve a variable's value.
 boolean isDependency(java.lang.String validatorName)
          Checks if the validator is listed as a dependency.
 boolean isIndexed()
          If there is a value specified for the indexedProperty field then true will be returned.
 void process(java.util.Map globalConstants, java.util.Map constants)
          Deprecated. This method is called by the framework. It will be made protected in a future release. TODO
 void processMessageComponents(java.lang.String key, java.lang.String replaceValue)
          Deprecated. This is an internal setup method that clients don't need to call.
 void setDepends(java.lang.String depends)
          Sets the validation rules for this field as a comma separated list.
 void setFieldOrder(int fieldOrder)
          Sets the position of the Field in the validation list.
 void setIndexedListProperty(java.lang.String indexedListProperty)
          Sets the indexed property name of the field.
 void setIndexedProperty(java.lang.String indexedProperty)
          Sets the indexed property name of the field.
 void setKey(java.lang.String key)
          Sets a unique key for the field.
 void setPage(int page)
          Sets the page value that the Field is associated with for validation.
 void setProperty(java.lang.String property)
          Sets the property name of the field.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ARG_DEFAULT

public static final java.lang.String ARG_DEFAULT
Deprecated.  

This is the value that will be used as a key if the Arg name field has no value.

See Also:
Constant Field Values

TOKEN_INDEXED

public static final java.lang.String TOKEN_INDEXED
This indicates an indexed property is being referenced.

See Also:
Constant Field Values

TOKEN_START

protected static final java.lang.String TOKEN_START
See Also:
Constant Field Values

TOKEN_END

protected static final java.lang.String TOKEN_END
See Also:
Constant Field Values

TOKEN_VAR

protected static final java.lang.String TOKEN_VAR
See Also:
Constant Field Values

property

protected java.lang.String property

indexedProperty

protected java.lang.String indexedProperty

indexedListProperty

protected java.lang.String indexedListProperty

key

protected java.lang.String key

depends

protected java.lang.String depends
A comma separated list of validator's this field depends on.


page

protected int page

fieldOrder

protected int fieldOrder

hDependencies

protected org.apache.commons.collections.FastHashMap hDependencies
Deprecated. This is no longer used.


hVars

protected org.apache.commons.collections.FastHashMap hVars

hMsgs

protected org.apache.commons.collections.FastHashMap hMsgs

args

protected java.util.Map[] args
Holds Maps of arguments. args[0] returns the Map for the first replacement argument. Start with a 0 length array so that it will only grow to the size of the highest argument position.

Since:
Validator 1.1

hArg0

protected org.apache.commons.collections.FastHashMap hArg0
Deprecated. This variable is no longer used, use args instead.


hArg1

protected org.apache.commons.collections.FastHashMap hArg1
Deprecated. This variable is no longer used, use args instead.


hArg2

protected org.apache.commons.collections.FastHashMap hArg2
Deprecated. This variable is no longer used, use args instead.


hArg3

protected org.apache.commons.collections.FastHashMap hArg3
Deprecated. This variable is no longer used, use args instead.

Constructor Detail

Field

public Field()
Method Detail

getPage

public int getPage()
Gets the page value that the Field is associated with for validation.


setPage

public void setPage(int page)
Sets the page value that the Field is associated with for validation.


getFieldOrder

public int getFieldOrder()
Gets the position of the Field in the validation list.


setFieldOrder

public void setFieldOrder(int fieldOrder)
Sets the position of the Field in the validation list.


getProperty

public java.lang.String getProperty()
Gets the property name of the field.


setProperty

public void setProperty(java.lang.String property)
Sets the property name of the field.


getIndexedProperty

public java.lang.String getIndexedProperty()
Gets the indexed property name of the field. This is the method name that can take an int as a parameter for indexed property value retrieval.


setIndexedProperty

public void setIndexedProperty(java.lang.String indexedProperty)
Sets the indexed property name of the field.


getIndexedListProperty

public java.lang.String getIndexedListProperty()
Gets the indexed property name of the field. This is the method name that will return an array or a Collection used to retrieve the list and then loop through the list performing the specified validations.


setIndexedListProperty

public void setIndexedListProperty(java.lang.String indexedListProperty)
Sets the indexed property name of the field.


getDepends

public java.lang.String getDepends()
Gets the validation rules for this field as a comma separated list.


setDepends

public void setDepends(java.lang.String depends)
Sets the validation rules for this field as a comma separated list.

Parameters:
depends - A comma separated list of validator names.

addMsg

public void addMsg(Msg msg)
Add a Msg to the Field.


getMsg

public java.lang.String getMsg(java.lang.String key)
Retrieve a message value.


addArg

public void addArg(Arg arg)
Add an Arg to the replacement argument list.

Since:
Validator 1.1

getArg

public Arg getArg(int position)
Gets the default Arg object at the given position.

Returns:
The default Arg or null if not found.
Since:
Validator 1.1

getArg

public Arg getArg(java.lang.String key,
                  int position)
Gets the Arg object at the given position. If the key finds a null value then the default value will be retrieved.

Parameters:
key - The name the Arg is stored under. If not found, the default Arg for the given position (if any) will be retrieved.
position - The Arg number to find.
Returns:
The Arg with the given name and position or null if not found.
Since:
Validator 1.1

getArgs

public Arg[] getArgs(java.lang.String key)
Retrieves the Args for the given validator name.

Parameters:
key - The validator's args to retrieve.
Returns:
An Arg[] sorted by the Args' positions (i.e. the Arg at index 0 has a position of 0).
Since:
Validator 1.1.1

addArg0

public void addArg0(Arg arg)
Deprecated. Use addArg(Arg) instead.

Add a Arg to the arg0 list.


getArg0

public Arg getArg0()
Deprecated. Use getArg(0) instead.

Gets the default arg0 Arg object.


getArg0

public Arg getArg0(java.lang.String key)
Deprecated. Use getArg(String, 0) instead.

Gets the arg0 Arg object based on the key passed in. If the key finds a null value then the default value will be retrieved.


addArg1

public void addArg1(Arg arg)
Deprecated. Use addArg(Arg) instead.

Add a Arg to the arg1 list.


getArg1

public Arg getArg1()
Deprecated. Use getArg(1) instead.

Gets the default arg1 Arg object.


getArg1

public Arg getArg1(java.lang.String key)
Deprecated. Use getArg(String, 1) instead.

Gets the arg1 Arg object based on the key passed in. If the key finds a null value then the default value will try to be retrieved.


addArg2

public void addArg2(Arg arg)
Deprecated. Use addArg(Arg) instead.

Add a Arg to the arg2 list.


getArg2

public Arg getArg2()
Deprecated. Use getArg(2) instead.

Gets the default arg2 Arg object.


getArg2

public Arg getArg2(java.lang.String key)
Deprecated. Use getArg(String, 2) instead.

Gets the arg2 Arg object based on the key passed in. If the key finds a null value then the default value will try to be retrieved.


addArg3

public void addArg3(Arg arg)
Deprecated. Use addArg(Arg) instead.

Add a Arg to the arg3 list.


getArg3

public Arg getArg3()
Deprecated. Use getArg(3) instead.

Gets the default arg3 Arg object.


getArg3

public Arg getArg3(java.lang.String key)
Deprecated. Use getArg(String, 3) instead.

Gets the arg3 Arg object based on the key passed in. If the key finds a null value then the default value will try to be retrieved.


addVar

public void addVar(Var v)
Add a Var to the Field.


addVarParam

public void addVarParam(java.lang.String name,
                        java.lang.String value,
                        java.lang.String jsType)
Deprecated. Use addVar(String, String, String) instead.

Add a Var, based on the values passed in, to the Field.


addVar

public void addVar(java.lang.String name,
                   java.lang.String value,
                   java.lang.String jsType)
Add a Var, based on the values passed in, to the Field.

Parameters:
name -
value -
jsType -

getVar

public Var getVar(java.lang.String mainKey)
Retrieve a variable.

Parameters:
mainKey -

getVarValue

public java.lang.String getVarValue(java.lang.String mainKey)
Retrieve a variable's value.

Parameters:
mainKey -

getVars

public java.util.Map getVars()
The Field's variables are returned as an unmodifiable Map.


getKey

public java.lang.String getKey()
Gets a unique key based on the property and indexedProperty fields.


setKey

public void setKey(java.lang.String key)
Sets a unique key for the field. This can be used to change the key temporarily to have a unique key for an indexed field.

Parameters:
key -

isIndexed

public boolean isIndexed()
If there is a value specified for the indexedProperty field then true will be returned. Otherwise it will be false.


generateKey

public void generateKey()
Generate correct key value.


process

public void process(java.util.Map globalConstants,
                    java.util.Map constants)
Deprecated. This method is called by the framework. It will be made protected in a future release. TODO

Replace constants with values in fields and process the depends field to create the dependency Map.


processMessageComponents

public void processMessageComponents(java.lang.String key,
                                     java.lang.String replaceValue)
Deprecated. This is an internal setup method that clients don't need to call.

Replace the args key value with the key/value pairs passed in.


isDependency

public boolean isDependency(java.lang.String validatorName)
Checks if the validator is listed as a dependency.


getDependencies

public java.util.Collection getDependencies()
Deprecated. Use getDependencyList() instead.

Gets an unmodifiable Set of the dependencies.


getDependencyList

public java.util.List getDependencyList()
Gets an unmodifiable List of the dependencies in the same order they were defined in parameter passed to the setDepends() method.


clone

public java.lang.Object clone()
Creates and returns a copy of this object.


toString

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



Copyright © 2002-2004 The Apache Software Foundation. All Rights Reserved.