Package org.apache.commons.validator
Class ValidatorAction
java.lang.Object
org.apache.commons.validator.ValidatorAction
- All Implemented Interfaces:
Serializable
Contains the information to dynamically create and run a validation
method. This is the class representation of a pluggable validator that can
be defined in an xml file with the <validator> element.
Note: The validation method is assumed to be thread safe.
- Version:
- $Revision: 1739361 $
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the class of the validator action.Returns the dependent validator names as an unmodifiableList
.Gets the dependencies of the validator action as a comma separated list of validator names.Gets the Javascript equivalent of the java class and method associated with this action.Gets the Javascript function name.Gets the name of method being called for the validator action.Gets the method parameters for the method.getMsg()
Gets the message associated with the validator action.getName()
Gets the name of the validator action.protected void
init()
Initialize based on set.boolean
isDependency
(String validatorName) Checks whether or not the value passed in is in the depends field.protected void
Load the javascript function specified by the given path.void
setClassname
(String classname) Sets the class of the validator action.void
setDepends
(String depends) Sets the dependencies of the validator action.void
setJavascript
(String javascript) Sets the Javascript equivalent of the java class and method associated with this action.void
setJsFunction
(String jsFunction) Sets the fully qualified class path of the Javascript function.void
setJsFunctionName
(String jsFunctionName) Sets the Javascript function name.void
Sets the name of method being called for the validator action.void
setMethodParams
(String methodParams) Sets the method parameters for the method.void
Sets the message associated with the validator action.void
Sets the name of the validator action.toString()
Returns a string representation of the object.
-
Constructor Details
-
ValidatorAction
public ValidatorAction()
-
-
Method Details
-
getName
Gets the name of the validator action.- Returns:
- Validator Action name.
-
setName
Sets the name of the validator action.- Parameters:
name
- Validator Action name.
-
getClassname
Gets the class of the validator action.- Returns:
- Class name of the validator Action.
-
setClassname
Sets the class of the validator action.- Parameters:
classname
- Class name of the validator Action.
-
getMethod
Gets the name of method being called for the validator action.- Returns:
- The method name.
-
setMethod
Sets the name of method being called for the validator action.- Parameters:
method
- The method name.
-
getMethodParams
Gets the method parameters for the method.- Returns:
- Method's parameters.
-
setMethodParams
Sets the method parameters for the method.- Parameters:
methodParams
- A comma separated list of parameters.
-
getDepends
Gets the dependencies of the validator action as a comma separated list of validator names.- Returns:
- The validator action's dependencies.
-
setDepends
Sets the dependencies of the validator action.- Parameters:
depends
- A comma separated list of validator names.
-
getMsg
Gets the message associated with the validator action.- Returns:
- The message for the validator action.
-
setMsg
Sets the message associated with the validator action.- Parameters:
msg
- The message for the validator action.
-
getJsFunctionName
Gets the Javascript function name. This is optional and can be used instead of validator action name for the name of the Javascript function/object.- Returns:
- The Javascript function name.
-
setJsFunctionName
Sets the Javascript function name. This is optional and can be used instead of validator action name for the name of the Javascript function/object.- Parameters:
jsFunctionName
- The Javascript function name.
-
setJsFunction
Sets the fully qualified class path of the Javascript function.This is optional and can be used instead of the setJavascript(). Attempting to call both
setJsFunction
andsetJavascript
will result in anIllegalStateException
being thrown.If neither setJsFunction or setJavascript is set then validator will attempt to load the default javascript definition.
Examples If in the validator.xml : #1: <validator name="tire" jsFunction="com.yourcompany.project.tireFuncion"> Validator will attempt to load com.yourcompany.project.validateTireFunction.js from its class path. #2: <validator name="tire"> Validator will use the name attribute to try and load org.apache.commons.validator.javascript.validateTire.js which is the default javascript definition.
- Parameters:
jsFunction
- The Javascript function's fully qualified class path.
-
getJavascript
Gets the Javascript equivalent of the java class and method associated with this action.- Returns:
- The Javascript validation.
-
setJavascript
Sets the Javascript equivalent of the java class and method associated with this action.- Parameters:
javascript
- The Javascript validation.
-
init
protected void init()Initialize based on set. -
loadJavascriptFunction
protected void loadJavascriptFunction()Load the javascript function specified by the given path. For this implementation, thejsFunction
property should contain a fully qualified package and script name, separated by periods, to be loaded from the class loader that created this instance. TODO if the path begins with a '/' the path will be intepreted as absolute, and remain unchanged. If this fails then it will attempt to treat the path as a file path. It is assumed the script ends with a '.js'. -
isDependency
Checks whether or not the value passed in is in the depends field.- Parameters:
validatorName
- Name of the dependency to check.- Returns:
- Whether the named validator is a dependant.
-
getDependencyList
Returns the dependent validator names as an unmodifiableList
.- Returns:
- List of the validator action's depedents.
-
toString
Returns a string representation of the object.
-