|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.validator.Field
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.
Form
,
Serialized FormField Summary | |
static java.lang.String |
ARG_DEFAULT
Deprecated. |
protected java.util.Map[] |
args
Holds Maps of arguments. |
private static java.lang.String |
DEFAULT_ARG
This is the value that will be used as a key if the Arg
name field has no value. |
private java.util.List |
dependencyList
Internal representation of this.depends String as a List. |
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. |
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(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. |
(package private) java.lang.Object[] |
getIndexedProperty(java.lang.Object bean)
Returns an indexed property from the object we're validating. |
java.lang.String |
getKey()
Gets a unique key based on the property and indexedProperty fields. |
Msg |
getMessage(java.lang.String key)
Retrieve a message object. |
java.util.Map |
getMessages()
The Field 's messages are returned as an
unmodifiable Map . |
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. |
private void |
handleMissingAction(java.lang.String name)
Called when a validator name is used in a depends clause but there is no know ValidatorAction configured for that name. |
private void |
internalProcessMessageComponents(java.lang.String key,
java.lang.String replaceValue)
Replace the args key value with the key/value pairs passed in. |
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 |
private void |
processArg(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)
Deprecated. This is an internal setup method that clients don't need to call. |
private void |
processVars(java.lang.String key,
java.lang.String replaceValue)
Replace the vars value with the key/value pairs passed in. |
private boolean |
runDependentValidators(ValidatorAction va,
ValidatorResults results,
java.util.Map actions,
java.util.Map params,
int pos)
Calls all of the validators that this validator depends on. |
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. |
(package private) ValidatorResults |
validate(java.util.Map params,
java.util.Map actions)
Run the configured validations on this field. |
private boolean |
validateForRule(ValidatorAction va,
ValidatorResults results,
java.util.Map actions,
java.util.Map params,
int pos)
Executes the given ValidatorAction and all ValidatorActions that it depends on. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final java.lang.String DEFAULT_ARG
Arg
name field has no value.
public static final java.lang.String ARG_DEFAULT
Arg
name field has no value.
public static final java.lang.String TOKEN_INDEXED
protected static final java.lang.String TOKEN_START
protected static final java.lang.String TOKEN_END
protected static final java.lang.String TOKEN_VAR
protected java.lang.String property
protected java.lang.String indexedProperty
protected java.lang.String indexedListProperty
protected java.lang.String key
protected java.lang.String depends
protected int page
protected int fieldOrder
protected org.apache.commons.collections.FastHashMap hDependencies
private java.util.List dependencyList
protected org.apache.commons.collections.FastHashMap hVars
protected org.apache.commons.collections.FastHashMap hMsgs
protected java.util.Map[] args
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
Constructor Detail |
public Field()
Method Detail |
public int getPage()
public void setPage(int page)
public int getFieldOrder()
Field
in the validation list.
public void setFieldOrder(int fieldOrder)
Field
in the validation list.
public java.lang.String getProperty()
public void setProperty(java.lang.String property)
public java.lang.String getIndexedProperty()
int
as
a parameter for indexed property value retrieval.
public void setIndexedProperty(java.lang.String indexedProperty)
public java.lang.String getIndexedListProperty()
Collection
used to retrieve the
list and then loop through the list performing the specified
validations.
public void setIndexedListProperty(java.lang.String indexedListProperty)
public java.lang.String getDepends()
public void setDepends(java.lang.String depends)
depends
- A comma separated list of validator names.public void addMsg(Msg msg)
Msg
to the Field
.
public java.lang.String getMsg(java.lang.String key)
public Msg getMessage(java.lang.String key)
public java.util.Map getMessages()
Field
's messages are returned as an
unmodifiable Map
.
public void addArg(Arg arg)
Arg
to the replacement argument list.
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.
public Arg getArg(java.lang.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(java.lang.String key)
key
- The validator's args to retrieve.
public void addArg0(Arg arg)
Arg
to the arg0 list.
public Arg getArg0()
Arg
object.
public Arg getArg0(java.lang.String key)
Arg
object based on the key passed in. If
the key finds a null
value then the default value will
be retrieved.
public void addArg1(Arg arg)
Arg
to the arg1 list.
public Arg getArg1()
Arg
object.
public Arg getArg1(java.lang.String key)
Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.
public void addArg2(Arg arg)
Arg
to the arg2 list.
public Arg getArg2()
Arg
object.
public Arg getArg2(java.lang.String key)
Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.
public void addArg3(Arg arg)
Arg
to the arg3 list.
public Arg getArg3()
Arg
object.
public Arg getArg3(java.lang.String key)
Arg
object based on the key passed in. If the key
finds a null
value then the default value will try to be retrieved.
public void addVar(Var v)
Var
to the Field
.
public void addVarParam(java.lang.String name, java.lang.String value, java.lang.String jsType)
Var
, based on the values passed in, to the
Field
.
public void addVar(java.lang.String name, java.lang.String value, java.lang.String jsType)
Var
, based on the values passed in, to the
Field
.
name
- value
- jsType
- public Var getVar(java.lang.String mainKey)
mainKey
- public java.lang.String getVarValue(java.lang.String mainKey)
mainKey
- public java.util.Map getVars()
Field
's variables are returned as an
unmodifiable Map
.
public java.lang.String getKey()
public void setKey(java.lang.String key)
key
- public boolean isIndexed()
true
will be returned. Otherwise it will be
false
.
public void generateKey()
key
value.
public void process(java.util.Map globalConstants, java.util.Map constants)
Map
.
private void processVars(java.lang.String key, java.lang.String replaceValue)
public void processMessageComponents(java.lang.String key, java.lang.String replaceValue)
private void internalProcessMessageComponents(java.lang.String key, java.lang.String replaceValue)
private void processArg(java.lang.String key, java.lang.String replaceValue)
Collection
key value with the key/value
pairs passed in.
public boolean isDependency(java.lang.String validatorName)
public java.util.Collection getDependencies()
Set
of the dependencies.
public java.util.List getDependencyList()
List
of the dependencies in the same
order they were defined in parameter passed to the setDepends() method.
public java.lang.Object clone()
public java.lang.String toString()
java.lang.Object[] getIndexedProperty(java.lang.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, java.util.Map actions, java.util.Map params, int pos) throws ValidatorException
ValidatorException
private boolean runDependentValidators(ValidatorAction va, ValidatorResults results, java.util.Map actions, java.util.Map params, int pos) throws ValidatorException
va
- Run dependent validators for this action.results
- actions
- pos
-
ValidatorException
ValidatorResults validate(java.util.Map params, java.util.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
private void handleMissingAction(java.lang.String name) throws ValidatorException
name
- The name of the validator in the depends list.
ValidatorException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |