org.apache.commons.validator
public class Field extends Object implements Cloneable, Serializable
The use of FastHashMap is deprecated and will be replaced in a future release.
Version: $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
See Also: Form
| Field Summary | |
|---|---|
| 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
The order of the Field in the Form. |
| protected FastHashMap | hMsgs |
| protected FastHashMap | hVars |
| 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. |
| Method Summary | |
|---|---|
| void | addArg(Arg arg)
Add an Arg to the replacement argument 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. |
| Object | clone()
Creates and returns a copy of this object. |
| void | determineArgPosition(Arg arg)
Calculate the position of the Arg |
| 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. |
| Object[] | getIndexedProperty(Object bean)
Returns an indexed property from the object we're validating.
|
| 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. |
| 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. |
| 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. |
Since: Validator 1.1
Arg
name field has no value.Deprecated: Subclasses should use getMsgMap() instead.
Deprecated: Subclasses should use getVarMap() instead.
Arg to the replacement argument list.Parameters: arg Validation message's argument.
Since: Validator 1.1
Msg to the Field.Parameters: msg A validation message.
Var to the Field.Parameters: v The Validator Argument.
Var, based on the values passed in, to the
Field.Parameters: name Name of the validation. value The Argument's value. jsType The Javascript type.
Returns: A copy of 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.Parameters: position Validation message argument's 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
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
List of the dependencies in the same
order they were defined in parameter passed to the setDepends() method.Returns: A list of the Field's dependancies.
Returns: A comma separated list of validator names.
Field in the validation list.Returns: The field position.
Collection used to retrieve the
list and then loop through the list performing the specified
validations.Returns: The field's indexed List property name.
int as
a parameter for indexed property value retrieval.Returns: The field's indexed property name.
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.
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.
Returns: a unique key for the field.
Parameters: key Validation key.
Returns: A validation message for a specified validator.
Since: Validator 1.1.4
Field's messages are returned as an
unmodifiable Map.Returns: Map of validation messages for the field.
Since: Validator 1.1.4
Parameters: key Validation key.
Returns: A validation message for a specified validator.
Returns: A Map of the Field's messages.
Since: Validator 1.2.0
Returns: The page number.
Returns: The field's property name.
Parameters: mainKey The Variable's key
Returns: the Variable
Returns: A Map of the Field's variables.
Since: Validator 1.2.0
Field's variables are returned as an
unmodifiable Map.Returns: the Map of Variable's for a Field.
Parameters: mainKey The Variable's key
Returns: the Variable's value
Parameters: name The name of the validator in the depends list.
Throws: ValidatorException
Parameters: validatorName Name of the validator to check.
Returns: Whether the field is dependant on a validator.
true will be returned. Otherwise it will be
false.Returns: Whether the Field is indexed.
Map.Collection 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 If there's an error running a validator
Parameters: depends A comma separated list of validator names.
Field in the validation list.Parameters: fieldOrder The field position.
Parameters: indexedListProperty The field's indexed List property name.
Parameters: indexedProperty The field's indexed property name.
Parameters: key a unique key for the field
Parameters: page The page number.
Parameters: property The field's property name.
Returns: A string representation of the object.
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.
Throws: ValidatorException If an error occurs during validation.
Returns: true if the validation succeeded.