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<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.
|
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.
|
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<String> |
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.
|
String |
getKey()
Gets a unique key based on the property and indexedProperty fields.
|
Msg |
getMessage(String key)
Retrieve a message object.
|
Map<String,Msg> |
getMessages()
The
Field 's messages are returned as an
unmodifiable Map . |
String |
getMsg(String key)
Retrieve a message value.
|
protected Map<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.
|
String |
getProperty()
Gets the property name of the field.
|
Var |
getVar(String mainKey)
Retrieve a variable.
|
protected Map<String,Var> |
getVarMap()
Returns a Map of String Var names to Var objects.
|
Map<String,Var> |
getVars()
The
Field 's variables are returned as an
unmodifiable Map . |
String |
getVarValue(String mainKey)
Retrieve a variable's value.
|
boolean |
isClientValidation()
Determines whether client-side scripting should be generated
for this field.
|
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 |
setClientValidation(boolean clientValidation)
Sets the flag that determines whether client-side scripting should
be generated for this field.
|
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<String,Object> params,
Map<String,ValidatorAction> actions)
Run the configured validations on this field.
|
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 boolean clientValidation
protected int fieldOrder
@Deprecated protected org.apache.commons.collections.FastHashMap hVars
@Deprecated protected org.apache.commons.collections.FastHashMap hMsgs
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<String,Msg> getMessages()
Field
's messages are returned as an
unmodifiable Map
.public boolean isClientValidation()
true
true
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.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<String,Var> 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.public boolean isDependency(String validatorName)
validatorName
- Name of the validator to check.public List<String> 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()
public ValidatorResults validate(Map<String,Object> params, Map<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.protected Map<String,Msg> getMsgMap()
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.