org.apache.commons.validator
Class Field

java.lang.Object
  |
  +--org.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.

Version:
$Revision: 1.7 $ $Date: 2002/10/16 22:13:32 $
Author:
David Winterfeldt
See Also:
Form, Serialized Form

Field Summary
static java.lang.String ARG_DEFAULT
          This is the value that will be used as a key if the Arg name field has no value.
protected  java.lang.String depends
           
protected  int fieldOrder
           
protected  org.apache.commons.collections.FastHashMap hArg0
           
protected  org.apache.commons.collections.FastHashMap hArg1
           
protected  org.apache.commons.collections.FastHashMap hArg2
           
protected  org.apache.commons.collections.FastHashMap hArg3
           
protected  org.apache.commons.collections.FastHashMap hDependencies
           
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 addArg0(Arg arg)
          Add a Arg to the arg0 list.
 void addArg1(Arg arg)
          Add a Arg to the arg1 list.
 void addArg2(Arg arg)
          Add a Arg to the arg2 list.
 void addArg3(Arg arg)
          Add a Arg to the arg3 list.
 void addMsg(Msg msg)
          Add a Msg 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)
          Add a Var, based on the values passed in, to the Field.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 void generateKey()
          Generate correct key value.
 Arg getArg0()
          Gets the default arg0 Arg object.
 Arg getArg0(java.lang.String key)
          Gets the arg0 Arg object based on the key passed in.
 Arg getArg1()
          Gets the default arg1 Arg object.
 Arg getArg1(java.lang.String key)
          Gets the arg1 Arg object based on the key passed in.
 Arg getArg2()
          Gets the default arg2 Arg object.
 Arg getArg2(java.lang.String key)
          Gets the arg2 Arg object based on the key passed in.
 Arg getArg3()
          Gets the default arg3 Arg object.
 Arg getArg3(java.lang.String key)
          Gets the arg3 Arg object based on the key passed in.
 java.util.Collection getDependencies()
          Gets an unmodifiable Set of the dependencies.
 java.lang.String getDepends()
          Gets the validation rules for this field.
 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 key)
          Checks if the key 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)
          Replace constants with values in fields and process the depends field to create the dependency Map.
private  void processArg(java.util.Map hArgs, java.lang.String key, java.lang.String replaceValue)
          Replace the arg Collection key value with the key/value pairs passed in.
 void processMessageComponents(java.lang.String key, java.lang.String replaceValue)
          Replace the args key value with the key/value pairs passed in.
private  void processVars(java.lang.String key, java.lang.String replaceValue)
          Replace the vars value with the key/value pairs passed in.
 void setDepends(java.lang.String depends)
          Sets the validation rules for this field.
 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, registerNatives, wait, wait, wait
 

Field Detail

ARG_DEFAULT

public static final java.lang.String ARG_DEFAULT
This is the value that will be used as a key if the Arg name field has no value.

TOKEN_INDEXED

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

TOKEN_START

protected static final java.lang.String TOKEN_START

TOKEN_END

protected static final java.lang.String TOKEN_END

TOKEN_VAR

protected static final java.lang.String TOKEN_VAR

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

page

protected int page

fieldOrder

protected int fieldOrder

hDependencies

protected org.apache.commons.collections.FastHashMap hDependencies

hVars

protected org.apache.commons.collections.FastHashMap hVars

hMsgs

protected org.apache.commons.collections.FastHashMap hMsgs

hArg0

protected org.apache.commons.collections.FastHashMap hArg0

hArg1

protected org.apache.commons.collections.FastHashMap hArg1

hArg2

protected org.apache.commons.collections.FastHashMap hArg2

hArg3

protected org.apache.commons.collections.FastHashMap hArg3
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.

setDepends

public void setDepends(java.lang.String depends)
Sets the validation rules for this field.

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.

addArg0

public void addArg0(Arg arg)
Add a Arg to the arg0 list.

getArg0

public Arg getArg0()
Gets the default arg0 Arg object.

getArg0

public Arg getArg0(java.lang.String key)
Gets the arg0 Arg object based on the key passed in. If the key finds a null value then the default value will try to be retrieved.

addArg1

public void addArg1(Arg arg)
Add a Arg to the arg1 list.

getArg1

public Arg getArg1()
Gets the default arg1 Arg object.

getArg1

public Arg getArg1(java.lang.String key)
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)
Add a Arg to the arg2 list.

getArg2

public Arg getArg2()
Gets the default arg2 Arg object.

getArg2

public Arg getArg2(java.lang.String key)
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)
Add a Arg to the arg3 list.

getArg3

public Arg getArg3()
Gets the default arg3 Arg object.

getArg3

public Arg getArg3(java.lang.String key)
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)
Add a Var, based on the values passed in, to the Field.

getVar

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

getVarValue

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

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.

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)
Replace constants with values in fields and process the depends field to create the dependency Map.

processVars

private void processVars(java.lang.String key,
                         java.lang.String replaceValue)
Replace the vars value with the key/value pairs passed in.

processMessageComponents

public void processMessageComponents(java.lang.String key,
                                     java.lang.String replaceValue)
Replace the args key value with the key/value pairs passed in.

processArg

private void processArg(java.util.Map hArgs,
                        java.lang.String key,
                        java.lang.String replaceValue)
Replace the arg Collection key value with the key/value pairs passed in.

isDependency

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

getDependencies

public java.util.Collection getDependencies()
Gets an unmodifiable Set of the dependencies.

clone

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

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object


Copyright (c) 2001-2002 - Apache Software Foundation