public class Field
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
The use of FastHashMap is deprecated and will be replaced in a future release.
Form,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,Arg>[] |
args
Holds Maps of arguments.
|
protected boolean |
clientValidation
The flag that indicates whether scripting should be generated
by the client for client-side validation.
|
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<java.lang.String> |
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
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 java.lang.String |
indexedListProperty
The Field's indexed list property name.
|
protected java.lang.String |
indexedProperty
The Field's indexed property name.
|
protected java.lang.String |
key
The Field's unique key.
|
protected int |
page
The Page Number
|
protected java.lang.String |
property
The Field's property name.
|
private static long |
serialVersionUID |
protected static java.lang.String |
TOKEN_END
The end of a token.
|
static java.lang.String |
TOKEN_INDEXED
This indicates an indexed property is being referenced.
|
protected static java.lang.String |
TOKEN_START
The start of a token.
|
protected static java.lang.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(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. |
java.lang.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(java.lang.String key,
int position)
Gets the
Arg object at the given position. |
Arg[] |
getArgs(java.lang.String key)
Retrieves the Args for the given validator name.
|
java.util.List<java.lang.String> |
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.
|
private int |
getIndexedPropertySize(java.lang.Object bean)
Returns the size of 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<java.lang.String,Msg> |
getMessages()
The
Field's messages are returned as an
unmodifiable Map. |
java.lang.String |
getMsg(java.lang.String key)
Retrieve a message value.
|
protected java.util.Map<java.lang.String,Msg> |
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.
|
java.lang.String |
getProperty()
Gets the property name of the field.
|
Var |
getVar(java.lang.String mainKey)
Retrieve a variable.
|
protected java.util.Map<java.lang.String,Var> |
getVarMap()
Returns a Map of String Var names to Var objects.
|
java.util.Map<java.lang.String,Var> |
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.
|
boolean |
isClientValidation()
Determines whether client-side scripting should be generated
for this field.
|
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. |
(package private) void |
process(java.util.Map<java.lang.String,java.lang.String> globalConstants,
java.util.Map<java.lang.String,java.lang.String> constants)
Replace constants with values in fields and process the depends field
to create the dependency
Map. |
private void |
processArg(java.lang.String key,
java.lang.String replaceValue)
Replace the arg
Collection key value with the key/value
pairs passed in. |
private 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.
|
private boolean |
runDependentValidators(ValidatorAction va,
ValidatorResults results,
java.util.Map<java.lang.String,ValidatorAction> actions,
java.util.Map<java.lang.String,java.lang.Object> params,
int pos)
Calls all of the validators that this validator depends on.
|
void |
setClientValidation(boolean clientValidation)
Sets the flag that determines whether client-side scripting should
be generated for this field.
|
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.
|
ValidatorResults |
validate(java.util.Map<java.lang.String,java.lang.Object> params,
java.util.Map<java.lang.String,ValidatorAction> actions)
Run the configured validations on this field.
|
private boolean |
validateForRule(ValidatorAction va,
ValidatorResults results,
java.util.Map<java.lang.String,ValidatorAction> actions,
java.util.Map<java.lang.String,java.lang.Object> params,
int pos)
Executes the given ValidatorAction and all ValidatorActions that it
depends on.
|
private static final long serialVersionUID
private static final java.lang.String DEFAULT_ARG
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 boolean clientValidation
protected int fieldOrder
private final java.util.List<java.lang.String> dependencyList
protected org.apache.commons.collections.FastHashMap hVars
protected org.apache.commons.collections.FastHashMap hMsgs
protected java.util.Map<java.lang.String,Arg>[] 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 java.lang.String getProperty()
public void setProperty(java.lang.String property)
property - The field's property name.public java.lang.String getIndexedProperty()
int as
a parameter for indexed property value retrieval.public void setIndexedProperty(java.lang.String indexedProperty)
indexedProperty - The field's indexed property name.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)
indexedListProperty - The field's indexed List property name.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.msg - A validation message.public java.lang.String getMsg(java.lang.String key)
key - Validation key.public Msg getMessage(java.lang.String key)
key - Validation key.public java.util.Map<java.lang.String,Msg> getMessages()
Field's messages are returned as an
unmodifiable Map.public boolean isClientValidation()
truetrue for scripting; otherwise falsesetClientValidation(boolean)public void setClientValidation(boolean clientValidation)
clientValidation - the scripting flagisClientValidation()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(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 addVar(Var v)
Var to the Field.v - The Validator Argument.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 - Name of the validation.value - The Argument's value.jsType - The Javascript type.public Var getVar(java.lang.String mainKey)
mainKey - The Variable's keypublic java.lang.String getVarValue(java.lang.String mainKey)
mainKey - The Variable's keypublic java.util.Map<java.lang.String,Var> getVars()
Field's variables are returned as an
unmodifiable Map.public java.lang.String getKey()
public void setKey(java.lang.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(java.util.Map<java.lang.String,java.lang.String> globalConstants,
java.util.Map<java.lang.String,java.lang.String> constants)
Map.private void processVars(java.lang.String key,
java.lang.String replaceValue)
private void processMessageComponents(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)
validatorName - Name of the validator to check.public java.util.List<java.lang.String> getDependencyList()
List of the dependencies in the same
order they were defined in parameter passed to the setDepends() method.public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectjava.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 int getIndexedPropertySize(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<java.lang.String,ValidatorAction> actions, java.util.Map<java.lang.String,java.lang.Object> params, int pos) throws ValidatorException
ValidatorExceptionprivate boolean runDependentValidators(ValidatorAction va, ValidatorResults results, java.util.Map<java.lang.String,ValidatorAction> actions, java.util.Map<java.lang.String,java.lang.Object> 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(java.util.Map<java.lang.String,java.lang.Object> params, java.util.Map<java.lang.String,ValidatorAction> 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(java.lang.String name)
throws ValidatorException
name - The name of the validator in the depends list.ValidatorExceptionprotected java.util.Map<java.lang.String,Msg> getMsgMap()
protected java.util.Map<java.lang.String,Var> getVarMap()