org.apache.commons.validator
public class Field extends Object implements Cloneable, Serializable
See Also: Form
Field Summary | |
---|---|
static String | ARG_DEFAULT
This is the value that will be used as a key if the Arg
name field has no value. |
protected Map[] | args
Holds Maps of arguments. args[0] returns the Map for the first
replacement argument. |
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. |
static String | DEFAULT_ARG
This is the value that will be used as a key if the Arg
name field has no value. |
protected int | fieldOrder |
protected FastHashMap | hArg0 |
protected FastHashMap | hArg1 |
protected FastHashMap | hArg2 |
protected FastHashMap | hArg3 |
protected FastHashMap | hDependencies |
protected FastHashMap | hMsgs |
protected FastHashMap | hVars |
protected String | indexedListProperty |
protected String | indexedProperty |
protected String | key |
protected int | page |
protected String | property |
protected static String | TOKEN_END |
static String | TOKEN_INDEXED
This indicates an indexed property is being referenced. |
protected static String | TOKEN_START |
protected static String | TOKEN_VAR |
Method Summary | |
---|---|
void | addArg(Arg arg)
Add an Arg to the replacement argument list. |
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 | addVar(String name, String value, String jsType)
Add a Var , based on the values passed in, to the
Field . |
void | addVarParam(String name, String value, String jsType)
Add a Var , based on the values passed in, to the
Field . |
Object | clone()
Creates and returns a copy of this object. |
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 | getArg0()
Gets the default arg0 Arg object. |
Arg | getArg0(String key)
Gets the arg0 Arg object based on the key passed in. |
Arg | getArg1()
Gets the default arg1 Arg object. |
Arg | getArg1(String key)
Gets the arg1 Arg object based on the key passed in. |
Arg | getArg2()
Gets the default arg2 Arg object. |
Arg | getArg2(String key)
Gets the arg2 Arg object based on the key passed in. |
Arg | getArg3()
Gets the default arg3 Arg object. |
Arg | getArg3(String key)
Gets the arg3 Arg object based on the key passed in. |
Arg[] | getArgs(String key)
Retrieves the Args for the given validator name. |
Collection | getDependencies()
Gets an unmodifiable Set of the dependencies. |
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. |
Object[] | getIndexedProperty(Object bean)
Returns 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. |
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. |
Map | getVars()
The Field 's variables are returned as an
unmodifiable Map . |
String | getVarValue(String mainKey)
Retrieve a variable's value. |
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. |
void | internalProcessMessageComponents(String key, String replaceValue)
Replace the args key value with the key/value pairs passed in.
|
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. |
void | process(Map globalConstants, Map constants)
Replace constants with values in fields and process the depends field
to create the dependency Map . |
void | processArg(String key, String replaceValue)
Replace the arg Collection key value with the key/value
pairs passed in. |
void | processMessageComponents(String key, String replaceValue)
Replace the args key value with the key/value pairs passed in. |
void | processVars(String key, String replaceValue)
Replace the vars value with the key/value pairs passed in. |
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. |
boolean | validateForRule(ValidatorAction va, ValidatorResults results, Map actions, Map params, int pos)
Executes the given ValidatorAction and all ValidatorActions that it
depends on. |
Deprecated:
This is the value that will be used as a key if theArg
name field has no value.Since: Validator 1.1
Arg
name field has no value.Deprecated: This variable is no longer used, use args instead.
Deprecated: This variable is no longer used, use args instead.
Deprecated: This variable is no longer used, use args instead.
Deprecated: This variable is no longer used, use args instead.
Deprecated: This is no longer used.
Arg
to the replacement argument list.Since: Validator 1.1
Deprecated: Use addArg(Arg) instead.
Add aArg
to the arg0 list.Deprecated: Use addArg(Arg) instead.
Add aArg
to the arg1 list.Deprecated: Use addArg(Arg) instead.
Add aArg
to the arg2 list.Deprecated: Use addArg(Arg) instead.
Add aArg
to the arg3 list.Msg
to the Field
.Var
to the Field
.Var
, based on the values passed in, to the
Field
.Parameters: name value jsType
Deprecated: Use addVar(String, String, String) instead.
Add aVar
, based on the values passed in, to the
Field
.Parameters: arg Determine if the args array is long enough to store this arg's position.
key
value.Arg
object at the given position.Returns: The default Arg or null if not found.
Since: Validator 1.1
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
Deprecated: Use getArg(0) instead.
Gets the default arg0Arg
object.Deprecated: Use getArg(String, 0) instead.
Gets the arg0Arg
object based on the key passed in. If
the key finds a null
value then the default value will
be retrieved.Deprecated: Use getArg(1) instead.
Gets the default arg1Arg
object.Deprecated: Use getArg(String, 1) instead.
Gets the arg1Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.Deprecated: Use getArg(2) instead.
Gets the default arg2Arg
object.Deprecated: Use getArg(String, 2) instead.
Gets the arg2Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.Deprecated: Use getArg(3) instead.
Gets the default arg3Arg
object.Deprecated: Use getArg(String, 3) instead.
Gets the arg3Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.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
Deprecated: Use getDependencyList() instead.
Gets an unmodifiableSet
of the dependencies.List
of the dependencies in the same
order they were defined in parameter passed to the setDepends() method.Field
in the validation list.Collection
used to retrieve the
list and then loop through the list performing the specified
validations.int
as
a parameter for indexed property value retrieval.Parameters: bean The bean to extract the indexed values from.
Throws: ValidatorException If there's an error looking up the property or, the property found is not indexed.
Since: Validator 1.1.4
Field
's messages are returned as an
unmodifiable Map
.Since: Validator 1.1.4
Parameters: mainKey
Field
's variables are returned as an
unmodifiable Map
.Parameters: mainKey
Parameters: name The name of the validator in the depends list.
Throws: ValidatorException
true
will be returned. Otherwise it will be
false
.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 dependencyMap
.Collection
key value with the key/value
pairs passed in.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.Parameters: va Run dependent validators for this action. results actions pos
Returns: true if all of the dependent validations passed.
Throws: ValidatorException
Parameters: depends A comma separated list of validator names.
Field
in the validation list.Parameters: key
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.
Returns: A ValidatorResults object containing validation messages for this field.
Returns: true if the validation succeeded.