Class ParameterUtils


  • public class ParameterUtils
    extends Object
    Utility class for Parameters handling
    Author:
    iperdomo
    • Constructor Detail

      • ParameterUtils

        public ParameterUtils()
    • Method Detail

      • setParameterValue

        public static void setParameterValue​(ParameterValue parameterValue,
                                             org.codehaus.jettison.json.JSONObject requestValue)
      • setDefaultParameterValue

        public static void setDefaultParameterValue​(ParameterValue value)
      • getParameterDomainType

        public static DomainType getParameterDomainType​(Parameter parameter)
      • getParameterValue

        public static Object getParameterValue​(ParameterValue parameterValue)
        Returns an Object with the Value of the Parameter Value. This object can be a String, a java.util.Date, long, boolean or a BigDecimal.
        Parameters:
        parameterValue - the Parameter Value we want to get the Value from.
        Returns:
        the Value of the Parameter Value.
      • getParameterStringValue

        public static String getParameterStringValue​(ParameterValue parameterValue)
        Returns the String representation of the Value.
        Parameters:
        parameterValue - the Parameter Value we want to get the Value from.
        Returns:
        the Value of the Parameter Value.
      • getParameterFixedValue

        public static Object getParameterFixedValue​(Map<String,​String> parameters,
                                                    Parameter parameter)
        Returns the Fixed value of the given parameter. If the value is a JS expression it returns the result of the expression based on the parameters passed in from the request.
        Parameters:
        parameters - the parameters passed in from the request
        parameter - the parameter we want to get the Fixed Value from
        Returns:
        the Fixed Value of the parameter
      • getParameterDefaultValue

        public static Object getParameterDefaultValue​(Map<String,​String> parameters,
                                                      Parameter parameter,
                                                      javax.servlet.http.HttpSession session,
                                                      org.codehaus.jettison.json.JSONObject _context)
                                               throws ScriptException
        Returns the default value of the given parameter based on the request information.
        Parameters:
        parameters - the parameters passed in from the request
        parameter - the parameter to get the Default Value from
        session - the HttpSession of the request
        _context - the JSONObject with the context information of the request.
        Returns:
        the DefaultValue of the Parameter.
        Throws:
        ScriptException - Error occurred executing the script to calculate the defaultValue of the parameter
      • getJSExpressionResult

        public static Object getJSExpressionResult​(Map<String,​String> parameters,
                                                   javax.servlet.http.HttpSession session,
                                                   String expression)
                                            throws ScriptException
        Returns the result of evaluating the given JavaScript expression.
        Parameters:
        parameters - Map of Strings with the request map parameters.
        session - optional HttpSession object.
        expression - String with the JavaScript expression to be evaluated.
        Returns:
        an Object with the result of the expression evaluation.
        Throws:
        ScriptException - Error occurred in the script execution
      • buildRequestMap

        public static Map<String,​String> buildRequestMap​(javax.servlet.http.HttpServletRequest request)
        Returns a Map<String, String> with all parameters in the servlet request.
        Parameters:
        request - request taken in the servlet.
        Returns:
        a Map with all parameters in request.