Class ValidatorAction

  • All Implemented Interfaces:
    java.io.Serializable

    public class ValidatorAction
    extends java.lang.Object
    implements java.io.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.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ValidatorAction()
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String getClassname()
      Gets the class of the validator action.
      java.util.List<java.lang.String> getDependencyList()
      Returns the dependent validator names as an unmodifiable List.
      java.lang.String getDepends()
      Gets the dependencies of the validator action as a comma separated list of validator names.
      java.lang.String getJavascript()
      Gets the JavaScript equivalent of the Java class and method associated with this action.
      java.lang.String getJsFunctionName()
      Gets the JavaScript function name.
      java.lang.String getMethod()
      Gets the name of method being called for the validator action.
      java.lang.String getMethodParams()
      Gets the method parameters for the method.
      java.lang.String getMsg()
      Gets the message associated with the validator action.
      java.lang.String getName()
      Gets the name of the validator action.
      protected void init()
      Initialize based on set.
      boolean isDependency​(java.lang.String validatorName)
      Checks whether or not the value passed in is in the depends field.
      protected void loadJavascriptFunction()
      Load the JavaScript function specified by the given path.
      void setClassname​(java.lang.String className)
      Deprecated.
      void setClassName​(java.lang.String className)
      Sets the class of the validator action.
      void setDepends​(java.lang.String depends)
      Sets the dependencies of the validator action.
      void setJavascript​(java.lang.String javaScript)
      Sets the JavaScript equivalent of the Java class and method associated with this action.
      void setJsFunction​(java.lang.String jsFunction)
      Sets the fully qualified class path of the JavaScript function.
      void setJsFunctionName​(java.lang.String jsFunctionName)
      Sets the JavaScript function name.
      void setMethod​(java.lang.String method)
      Sets the name of method being called for the validator action.
      void setMethodParams​(java.lang.String methodParams)
      Sets the method parameters for the method.
      void setMsg​(java.lang.String msg)
      Sets the message associated with the validator action.
      void setName​(java.lang.String name)
      Sets the name of the validator action.
      java.lang.String toString()
      Returns a string representation of the object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getClassname

        public java.lang.String getClassname()
        Gets the class of the validator action.
        Returns:
        Class name of the validator Action.
      • getDependencyList

        public java.util.List<java.lang.String> getDependencyList()
        Returns the dependent validator names as an unmodifiable List.
        Returns:
        List of the validator action's dependents.
      • getDepends

        public java.lang.String getDepends()
        Gets the dependencies of the validator action as a comma separated list of validator names.
        Returns:
        The validator action's dependencies.
      • getJavascript

        public java.lang.String getJavascript()
        Gets the JavaScript equivalent of the Java class and method associated with this action.
        Returns:
        The JavaScript validation.
      • getJsFunctionName

        public java.lang.String 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.
      • getMethod

        public java.lang.String getMethod()
        Gets the name of method being called for the validator action.
        Returns:
        The method name.
      • getMethodParams

        public java.lang.String getMethodParams()
        Gets the method parameters for the method.
        Returns:
        Method's parameters.
      • getMsg

        public java.lang.String getMsg()
        Gets the message associated with the validator action.
        Returns:
        The message for the validator action.
      • getName

        public java.lang.String getName()
        Gets the name of the validator action.
        Returns:
        Validator Action name.
      • init

        protected void init()
        Initialize based on set.
      • isDependency

        public boolean isDependency​(java.lang.String validatorName)
        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.
      • loadJavascriptFunction

        protected void loadJavascriptFunction()
        Load the JavaScript function specified by the given path. For this implementation, the jsFunction 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 interpreted 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'.
      • setClassname

        @Deprecated
        public void setClassname​(java.lang.String className)
        Deprecated.
        Sets the class of the validator action.
        Parameters:
        className - Class name of the validator Action.
      • setClassName

        public void setClassName​(java.lang.String className)
        Sets the class of the validator action.
        Parameters:
        className - Class name of the validator Action.
      • setDepends

        public void setDepends​(java.lang.String depends)
        Sets the dependencies of the validator action.
        Parameters:
        depends - A comma separated list of validator names.
      • setJavascript

        public void setJavascript​(java.lang.String javaScript)
        Sets the JavaScript equivalent of the Java class and method associated with this action.
        Parameters:
        javaScript - The JavaScript validation.
      • setJsFunction

        public void setJsFunction​(java.lang.String jsFunction)
        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 and setJavascript will result in an IllegalStateException being thrown.

        If neither setJsFunction nor 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.
      • setJsFunctionName

        public void setJsFunctionName​(java.lang.String jsFunctionName)
        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.
      • setMethod

        public void setMethod​(java.lang.String method)
        Sets the name of method being called for the validator action.
        Parameters:
        method - The method name.
      • setMethodParams

        public void setMethodParams​(java.lang.String methodParams)
        Sets the method parameters for the method.
        Parameters:
        methodParams - A comma separated list of parameters.
      • setMsg

        public void setMsg​(java.lang.String msg)
        Sets the message associated with the validator action.
        Parameters:
        msg - The message for the validator action.
      • setName

        public void setName​(java.lang.String name)
        Sets the name of the validator action.
        Parameters:
        name - Validator Action name.
      • toString

        public java.lang.String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation.