public class Field extends Object implements Cloneable, Serializable
The use of FastHashMap is deprecated and will be replaced in a future release.
Form
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Map[] |
args
Holds Maps of arguments.
|
private static String |
DEFAULT_ARG
This is the value that will be used as a key if the
Arg
name field has no value. |
private List |
dependencyList
Internal representation of this.depends String as a List.
|
protected String |
depends
A comma separated list of validator's this field depends on.
|
protected int |
fieldOrder
The order of the Field in the Form.
|
protected org.apache.commons.collections.FastHashMap |
hMsgs
Deprecated.
Subclasses should use getMsgMap() instead.
|
protected org.apache.commons.collections.FastHashMap |
hVars
Deprecated.
Subclasses should use getVarMap() instead.
|
protected String |
indexedListProperty
The Field's indexed list property name.
|
protected String |
indexedProperty
The Field's indexed property name.
|
protected String |
key
The Field's unique key.
|
protected int |
page
The Page Number
|
protected String |
property
The Field's property name.
|
protected static String |
TOKEN_END
The end of a token.
|
static String |
TOKEN_INDEXED
This indicates an indexed property is being referenced.
|
protected static String |
TOKEN_START
The start of a token.
|
protected static String |
TOKEN_VAR
A Vriable token.
|
Constructor and Description |
---|
Field() |
Modifier and Type | Method and Description |
---|---|
void |
addArg(Arg arg)
Add an
Arg to the replacement argument list. |
void |
addMsg(Msg msg)
Add a
Msg to the Field . |
void |
addVar(String name,
String value,
String jsType)
Add a
Var , based on the values passed in, to the
Field . |
void |
addVar(Var v)
Add a
Var to the Field . |
Object |
clone()
Creates and returns a copy of this object.
|
private void |
determineArgPosition(Arg arg)
Calculate the position of the Arg
|
private void |
ensureArgsCapacity(Arg arg)
Ensures that the args array can hold the given arg.
|
void |
generateKey()
Generate correct
key value. |
Arg |
getArg(int position)
Gets the default
Arg object at the given position. |
Arg |
getArg(String key,
int position)
Gets the
Arg object at the given position. |
Arg[] |
getArgs(String key)
Retrieves the Args for the given validator name.
|
List |
getDependencyList()
Gets an unmodifiable
List of the dependencies in the same
order they were defined in parameter passed to the setDepends() method. |
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. |
String |
getIndexedListProperty()
Gets the indexed property name of the field.
|
String |
getIndexedProperty()
Gets the indexed property name of the field.
|
(package private) Object[] |
getIndexedProperty(Object bean)
Returns an indexed property from the object we're validating.
|
private int |
getIndexedPropertySize(Object bean)
Returns the size of an indexed property from the object we're validating.
|
String |
getKey()
Gets a unique key based on the property and indexedProperty fields.
|
Msg |
getMessage(String key)
Retrieve a message object.
|
Map |
getMessages()
The
Field 's messages are returned as an
unmodifiable Map . |
String |
getMsg(String key)
Retrieve a message value.
|
protected Map |
getMsgMap()
Returns a Map of String Msg names to Msg objects.
|
int |
getPage()
Gets the page value that the Field is associated with for
validation.
|
String |
getProperty()
Gets the property name of the field.
|
Var |
getVar(String mainKey)
Retrieve a variable.
|
protected Map |
getVarMap()
Returns a Map of String Var names to Var objects.
|
Map |
getVars()
The
Field 's variables are returned as an
unmodifiable Map . |
String |
getVarValue(String mainKey)
Retrieve a variable's value.
|
private void |
handleMissingAction(String name)
Called when a validator name is used in a depends clause but there is
no know ValidatorAction configured for that name.
|
boolean |
isDependency(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. |
(package private) void |
process(Map globalConstants,
Map constants)
Replace constants with values in fields and process the depends field
to create the dependency
Map . |
private void |
processArg(String key,
String replaceValue)
Replace the arg
Collection key value with the key/value
pairs passed in. |
private void |
processMessageComponents(String key,
String replaceValue)
Replace the args key value with the key/value pairs passed in.
|
private void |
processVars(String key,
String replaceValue)
Replace the vars value with the key/value pairs passed in.
|
private boolean |
runDependentValidators(ValidatorAction va,
ValidatorResults results,
Map actions,
Map params,
int pos)
Calls all of the validators that this validator depends on.
|
void |
setDepends(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(String indexedListProperty)
Sets the indexed property name of the field.
|
void |
setIndexedProperty(String indexedProperty)
Sets the indexed property name of the field.
|
void |
setKey(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(String property)
Sets the property name of the field.
|
String |
toString()
Returns a string representation of the object.
|
ValidatorResults |
validate(Map params,
Map actions)
Run the configured validations on this field.
|
private boolean |
validateForRule(ValidatorAction va,
ValidatorResults results,
Map actions,
Map params,
int pos)
Executes the given ValidatorAction and all ValidatorActions that it
depends on.
|
private static final String DEFAULT_ARG
Arg
name field has no value.public static final String TOKEN_INDEXED
protected static final String TOKEN_START
protected static final String TOKEN_END
protected static final String TOKEN_VAR
protected String property
protected String indexedProperty
protected String indexedListProperty
protected String key
protected String depends
protected int page
protected int fieldOrder
private List dependencyList
protected org.apache.commons.collections.FastHashMap hVars
protected org.apache.commons.collections.FastHashMap hMsgs
protected Map[] args
public int getPage()
public void setPage(int page)
page
- The page number.public int getFieldOrder()
Field
in the validation list.public void setFieldOrder(int fieldOrder)
Field
in the validation list.fieldOrder
- The field position.public String getProperty()
public void setProperty(String property)
property
- The field's property name.public String getIndexedProperty()
int
as
a parameter for indexed property value retrieval.public void setIndexedProperty(String indexedProperty)
indexedProperty
- The field's indexed property name.public String getIndexedListProperty()
Collection
used to retrieve the
list and then loop through the list performing the specified
validations.public void setIndexedListProperty(String indexedListProperty)
indexedListProperty
- The field's indexed List property name.public String getDepends()
public void setDepends(String depends)
depends
- A comma separated list of validator names.public void addMsg(Msg msg)
Msg
to the Field
.msg
- A validation message.public String getMsg(String key)
key
- Validation key.public Msg getMessage(String key)
key
- Validation key.public Map getMessages()
Field
's messages are returned as an
unmodifiable Map
.public void addArg(Arg arg)
Arg
to the replacement argument list.arg
- Validation message's argument.private void determineArgPosition(Arg arg)
private void ensureArgsCapacity(Arg arg)
arg
- Determine if the args array is long enough to store this arg's
position.public Arg getArg(int position)
Arg
object at the given position.position
- Validation message argument's position.public Arg getArg(String key, int position)
Arg
object at the given position. If the key
finds a null
value then the default value will be
retrieved.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.public Arg[] getArgs(String key)
key
- The validator's args to retrieve.public void addVar(Var v)
Var
to the Field
.v
- The Validator Argument.public void addVar(String name, String value, String jsType)
Var
, based on the values passed in, to the
Field
.name
- Name of the validation.value
- The Argument's value.jsType
- The Javascript type.public Var getVar(String mainKey)
mainKey
- The Variable's keypublic String getVarValue(String mainKey)
mainKey
- The Variable's keypublic Map getVars()
Field
's variables are returned as an
unmodifiable Map
.public String getKey()
public void setKey(String key)
key
- a unique key for the fieldpublic boolean isIndexed()
true
will be returned. Otherwise it will be
false
.public void generateKey()
key
value.void process(Map globalConstants, Map constants)
Map
.private void processVars(String key, String replaceValue)
private void processMessageComponents(String key, String replaceValue)
private void processArg(String key, String replaceValue)
Collection
key value with the key/value
pairs passed in.public boolean isDependency(String validatorName)
validatorName
- Name of the validator to check.public List getDependencyList()
List
of the dependencies in the same
order they were defined in parameter passed to the setDepends() method.public Object clone()
public String toString()
Object[] getIndexedProperty(Object bean) throws ValidatorException
bean
- The bean to extract the indexed values from.ValidatorException
- If there's an error looking up the property
or, the property found is not indexed.private int getIndexedPropertySize(Object bean) throws ValidatorException
bean
- The bean to extract the indexed values from.ValidatorException
- If there's an error looking up the property
or, the property found is not indexed.private boolean validateForRule(ValidatorAction va, ValidatorResults results, Map actions, Map params, int pos) throws ValidatorException
ValidatorException
private boolean runDependentValidators(ValidatorAction va, ValidatorResults results, Map actions, Map params, int pos) throws ValidatorException
va
- Run dependent validators for this action.results
- actions
- pos
- ValidatorException
- If there's an error running a validatorpublic ValidatorResults validate(Map params, Map actions) throws ValidatorException
params
- A Map of parameter class names to parameter values to pass
into validation methods.actions
- A Map of validator names to ValidatorAction objects.ValidatorException
- If an error occurs during validation.private void handleMissingAction(String name) throws ValidatorException
name
- The name of the validator in the depends list.ValidatorException
protected Map getMsgMap()
protected Map getVarMap()
Copyright (c) 2001-2004 Apache Software Foundation