|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.validator.Validator
Validations are processed by the validate method. An instance of
ValidatorResources
is used to define the validators
(validation methods) and the validation rules for a JavaBean.
Field Summary | |
static java.lang.String |
BEAN_KEY
Deprecated. Use BEAN_PARAM instead. |
static java.lang.String |
BEAN_PARAM
Resources key the JavaBean is stored to perform validation on. |
protected java.lang.ClassLoader |
classLoader
The class loader to use for instantiating application objects. |
static java.lang.String |
FIELD_KEY
Deprecated. Use FIELD_PARAM instead. |
static java.lang.String |
FIELD_PARAM
Resources key the Field is stored under. |
protected java.lang.String |
formName
|
protected java.util.HashMap |
hResources
Deprecated. Use parameters instead. |
static java.lang.String |
LOCALE_KEY
Deprecated. Use LOCALE_PARAM instead. |
static java.lang.String |
LOCALE_PARAM
Resources key the Locale is stored. |
protected static org.apache.commons.logging.Log |
log
Deprecated. Subclasses should use their own logging instance. |
protected boolean |
onlyReturnErrors
Set this to true to not return Fields that pass validation. |
protected int |
page
The current page number to validate. |
protected java.util.Map |
parameters
Maps validation method parameter class names to the objects to be passed into the method. |
protected ValidatorResources |
resources
|
protected boolean |
useContextClassLoader
Whether or not to use the Context ClassLoader when loading classes for instantiating new objects. |
static java.lang.String |
VALIDATOR_ACTION_KEY
Deprecated. Use VALIDATOR_ACTION_PARAM instead. |
static java.lang.String |
VALIDATOR_ACTION_PARAM
Resources key the ValidatorAction is stored under. |
static java.lang.String |
VALIDATOR_KEY
Deprecated. Use VALIDATOR_PARAM instead. |
static java.lang.String |
VALIDATOR_PARAM
Resources key the Validator is stored under. |
Constructor Summary | |
Validator(ValidatorResources resources)
Construct a Validator that will
use the ValidatorResources
passed in to retrieve pluggable validators
the different sets of validation rules. |
|
Validator(ValidatorResources resources,
java.lang.String formName)
Construct a Validator that will
use the ValidatorResources
passed in to retrieve pluggable validators
the different sets of validation rules. |
Method Summary | |
void |
addResource(java.lang.String parameterClassName,
java.lang.Object parameterValue)
Deprecated. Use setParameter(String, Object) instead. |
void |
clear()
Clears the form name, resources that were added, and the page that was set (if any). |
java.lang.ClassLoader |
getClassLoader()
Return the class loader to be used for instantiating application objects when required. |
java.lang.String |
getFormName()
Gets the form name which is the key to a set of validation rules. |
boolean |
getOnlyReturnErrors()
Returns true if the Validator is only returning Fields that fail validation. |
int |
getPage()
Gets the page. |
java.lang.Object |
getParameterValue(java.lang.String parameterClassName)
Returns the value of the specified parameter that will be used during the processing of validations. |
java.lang.Object |
getResource(java.lang.String parameterClassName)
Deprecated. Use getParameterValue(String) instead. |
boolean |
getUseContextClassLoader()
Return the boolean as to whether the context classloader should be used. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader to be used for instantiating application objects when required. |
void |
setFormName(java.lang.String formName)
Sets the form name which is the key to a set of validation rules. |
void |
setOnlyReturnErrors(boolean onlyReturnErrors)
Configures which Fields the Validator returns from the validate() method. |
void |
setPage(int page)
Sets the page. |
void |
setParameter(java.lang.String parameterClassName,
java.lang.Object parameterValue)
Set a parameter of a pluggable validation method. |
void |
setUseContextClassLoader(boolean use)
Determine whether to use the Context ClassLoader (the one found by calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes that are defined in various rules. |
ValidatorResults |
validate()
Performs validations based on the configured resources. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.commons.logging.Log log
public static final java.lang.String BEAN_PARAM
public static final java.lang.String BEAN_KEY
public static final java.lang.String VALIDATOR_ACTION_PARAM
ValidatorAction
is stored under.
This will be automatically passed into a validation method
with the current ValidatorAction
if it is
specified in the method signature.
public static final java.lang.String VALIDATOR_ACTION_KEY
ValidatorAction
is stored under.
This will be automatically passed into a validation method
with the current ValidatorAction
if it is
specified in the method signature.
public static final java.lang.String FIELD_PARAM
Field
is stored under.
This will be automatically passed into a validation method
with the current Field
if it is
specified in the method signature.
public static final java.lang.String FIELD_KEY
Field
is stored under.
This will be automatically passed into a validation method
with the current Field
if it is
specified in the method signature.
public static final java.lang.String VALIDATOR_PARAM
Validator
is stored under.
This will be automatically passed into a validation method
with the current Validator
if it is
specified in the method signature.
public static final java.lang.String VALIDATOR_KEY
Validator
is stored under.
This will be automatically passed into a validation method
with the current Validator
if it is
specified in the method signature.
public static final java.lang.String LOCALE_PARAM
Locale
is stored.
This will be used to retrieve the appropriate
FormSet
and Form
to be
processed.
public static final java.lang.String LOCALE_KEY
Locale
is stored.
This will be used to retrieve the appropriate
FormSet
and Form
to be
processed.
protected ValidatorResources resources
protected java.lang.String formName
protected java.util.Map parameters
protected java.util.HashMap hResources
protected int page
protected java.lang.ClassLoader classLoader
useContextClassLoader
variable.
protected boolean useContextClassLoader
false
.
protected boolean onlyReturnErrors
Constructor Detail |
public Validator(ValidatorResources resources)
Validator
that will
use the ValidatorResources
passed in to retrieve pluggable validators
the different sets of validation rules.
resources
- ValidatorResources
to use during validation.public Validator(ValidatorResources resources, java.lang.String formName)
Validator
that will
use the ValidatorResources
passed in to retrieve pluggable validators
the different sets of validation rules.
resources
- ValidatorResources
to use during validation.formName
- Key used for retrieving the set of validation rules.Method Detail |
public void addResource(java.lang.String parameterClassName, java.lang.Object parameterValue)
parameterClassName
- The full class name of the parameter of the
validation method that corresponds to the value/instance passed in with it.parameterValue
- The instance that will be passed into the
validation method.public void setParameter(java.lang.String parameterClassName, java.lang.Object parameterValue)
parameterClassName
- The full class name of the parameter of the
validation method that corresponds to the value/instance passed in with it.parameterValue
- The instance that will be passed into the
validation method.public java.lang.Object getResource(java.lang.String parameterClassName)
parameterClassName
- The full class name of the parameter of the
validation method that corresponds to the value/instance passed in with it.public java.lang.Object getParameterValue(java.lang.String parameterClassName)
parameterClassName
- The full class name of the parameter of the
validation method that corresponds to the value/instance passed in with it.public java.lang.String getFormName()
public void setFormName(java.lang.String formName)
public int getPage()
Field can control the processing of fields. If the field's
page is less than or equal to this page value, it will be processed.
public void setPage(int page)
Field can control the processing of fields. If the field's page
is less than or equal to this page value, it will be processed.
public void clear()
ValidatorResources
will not be removed since it can be used
again and is thread safe.
public boolean getUseContextClassLoader()
public void setUseContextClassLoader(boolean use)
Thread.currentThread().getContextClassLoader()
)
to resolve/load classes that are defined in various rules. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader.
use
- determines whether to use Context ClassLoader.public java.lang.ClassLoader getClassLoader()
setClassLoader()
, if anyuseContextClassLoader
property is set to true
public void setClassLoader(java.lang.ClassLoader classLoader)
classLoader
- The new class loader to use, or null
to revert to the standard rulespublic ValidatorResults validate() throws ValidatorException
Map
returned uses the property of the
Field
for the key and the value is the number of error the
field had.
ValidatorException
public boolean getOnlyReturnErrors()
public void setOnlyReturnErrors(boolean onlyReturnErrors)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |