| Method from org.apache.commons.validator.Validator Detail: |
public void clear() {
this.formName = null;
this.fieldName = null;
this.parameters = new HashMap();
this.page = 0;
}
Clears the form name, resources that were added, and the page that was
set (if any). This can be called to reinitialize the Validator instance
so it can be reused. The form name (key to set of validation rules) and any
resources needed, like the JavaBean being validated, will need to
set and/or added to this instance again. The
ValidatorResources will not be removed since it can be used
again and is thread safe. |
public ClassLoader getClassLoader() {
if (this.classLoader != null) {
return this.classLoader;
}
if (this.useContextClassLoader) {
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
if (contextLoader != null) {
return contextLoader;
}
}
return this.getClass().getClassLoader();
}
Return the class loader to be used for instantiating application objects
when required. This is determined based upon the following rules:
- The class loader set by
setClassLoader(), if any
- The thread context class loader, if it exists and the
useContextClassLoader property is set to true
- The class loader used to load the Digester class itself.
|
public String getFormName() {
return formName;
}
Gets the form name which is the key to a set of validation rules. |
public boolean getOnlyReturnErrors() {
return onlyReturnErrors;
}
Returns true if the Validator is only returning Fields that fail validation. |
public int getPage() {
return page;
}
Gets the page. This in conjunction with the page property of
a 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 Object getParameterValue(String parameterClassName) {
return this.parameters.get(parameterClassName);
}
Returns the value of the specified parameter that will be used during the
processing of validations. |
public boolean getUseContextClassLoader() {
return this.useContextClassLoader;
}
Return the boolean as to whether the context classloader should be used. |
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
Set the class loader to be used for instantiating application objects
when required. |
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
Sets the name of the field to validate in a form (optional) |
public void setFormName(String formName) {
this.formName = formName;
}
Sets the form name which is the key to a set of validation rules. |
public void setOnlyReturnErrors(boolean onlyReturnErrors) {
this.onlyReturnErrors = onlyReturnErrors;
}
Configures which Fields the Validator returns from the validate() method. Set this
to true to only return Fields that failed validation. By default, validate() returns
all fields. |
public void setPage(int page) {
this.page = page;
}
Sets the page. This in conjunction with the page property of
a 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 setParameter(String parameterClassName,
Object parameterValue) {
this.parameters.put(parameterClassName, parameterValue);
}
Set a parameter of a pluggable validation method. |
public void setUseContextClassLoader(boolean use) {
this.useContextClassLoader = 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. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader. |
public ValidatorResults validate() throws ValidatorException {
Locale locale = (Locale) this.getParameterValue(LOCALE_PARAM);
if (locale == null) {
locale = Locale.getDefault();
}
this.setParameter(VALIDATOR_PARAM, this);
Form form = this.resources.getForm(locale, this.formName);
if (form != null) {
this.setParameter(FORM_PARAM, form);
return form.validate(
this.parameters,
this.resources.getValidatorActions(),
this.page,
this.fieldName);
}
return new ValidatorResults();
}
Performs validations based on the configured resources. |