Class ParamUtils

java.lang.Object
org.jivesoftware.util.ParamUtils

public class ParamUtils extends Object
Assists JSP writers in getting parameters and attributes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getAttribute(javax.servlet.http.HttpServletRequest request, String name)
    Returns an attribute as a string.
    static String
    getAttribute(javax.servlet.http.HttpServletRequest request, String name, boolean emptyStringsOK)
    Returns an attribute as a string.
    static boolean
    getBooleanAttribute(javax.servlet.http.HttpServletRequest request, String name)
    Returns an attribute as a boolean.
    static boolean
    getBooleanParameter(javax.servlet.http.HttpServletRequest request, String name)
    Returns a parameter as a boolean.
    static boolean
    getBooleanParameter(javax.servlet.http.HttpServletRequest request, String name, boolean defaultVal)
    Returns a parameter as a boolean.
    static double
    getDoubleParameter(javax.servlet.http.HttpServletRequest request, String name, double defaultNum)
    Returns a parameter as a double.
    static int
    getIntAttribute(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
    Returns an attribute as a int.
    static int
    getIntParameter(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
    Returns a parameter as an int.
    static int[]
    getIntParameters(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
    Returns a list of int parameters.
    static long
    getLongAttribute(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
    Returns an attribute as a long.
    static long
    getLongParameter(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
    Returns a parameter as a long.
    static long[]
    getLongParameters(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
    Returns a list of long parameters.
    static String
    getParameter(javax.servlet.http.HttpServletRequest request, String name)
    Returns a parameter as a string.
    static String
    getParameter(javax.servlet.http.HttpServletRequest request, String name, boolean emptyStringsOK)
    Returns a parameter as a string.
    static String[]
    getParameters(javax.servlet.http.HttpServletRequest request, String name)
    Returns a list of parameters of the same name
    static String
    getStringParameter(javax.servlet.http.HttpServletRequest request, String name, String defaultVal)
    Returns a parameter as a String.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ParamUtils

      public ParamUtils()
  • Method Details

    • getParameter

      public static String getParameter(javax.servlet.http.HttpServletRequest request, String name)
      Returns a parameter as a string.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      Returns:
      the value of the parameter or null if the parameter was not found or if the parameter is a zero-length string.
    • getParameter

      public static String getParameter(javax.servlet.http.HttpServletRequest request, String name, boolean emptyStringsOK)
      Returns a parameter as a string.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      emptyStringsOK - return the parameter values even if it is an empty string.
      Returns:
      the value of the parameter or null if the parameter was not found.
    • getParameters

      public static String[] getParameters(javax.servlet.http.HttpServletRequest request, String name)
      Returns a list of parameters of the same name
      Parameters:
      request - an HttpServletRequest object.
      name - the name of the parameter you want to get
      Returns:
      an array of non-null, non-blank strings of the same name. This method will return an empty array if no parameters were found.
    • getStringParameter

      public static String getStringParameter(javax.servlet.http.HttpServletRequest request, String name, String defaultVal)
      Returns a parameter as a String.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultVal - the value to use if the supplied parameter is not present or is empty
      Returns:
      either the value of parameter in the request, or the defaultVal
    • getBooleanParameter

      public static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request, String name)
      Returns a parameter as a boolean.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      Returns:
      true if the value of the parameter was "true", false otherwise.
    • getBooleanParameter

      public static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request, String name, boolean defaultVal)
      Returns a parameter as a boolean.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultVal - the default value if the parameter is not present
      Returns:
      true if the value of the parameter was "true", false otherwise.
    • getIntParameter

      public static int getIntParameter(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
      Returns a parameter as an int.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultNum - the default value if the parameter is not present/could not be parsed
      Returns:
      the int value of the parameter specified or the default value if the parameter is not found.
    • getIntParameters

      public static int[] getIntParameters(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
      Returns a list of int parameters.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultNum - the default value of a parameter, if the parameter can't be converted into an int.
      Returns:
      an array of integers
    • getDoubleParameter

      public static double getDoubleParameter(javax.servlet.http.HttpServletRequest request, String name, double defaultNum)
      Returns a parameter as a double.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultNum - the default value if the parameter is not present/could not be parsed
      Returns:
      the double value of the parameter specified or the default value if the parameter is not found.
    • getLongParameter

      public static long getLongParameter(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
      Returns a parameter as a long.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultNum - the default value of a parameter, if the parameter can't be converted into a long.
      Returns:
      the long value of the parameter specified or the default value if the parameter is not found.
    • getLongParameters

      public static long[] getLongParameters(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
      Returns a list of long parameters.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      defaultNum - the default value of a parameter, if the parameter can't be converted into a long.
      Returns:
      an array of long parameters
    • getAttribute

      public static String getAttribute(javax.servlet.http.HttpServletRequest request, String name)
      Returns an attribute as a string.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get
      Returns:
      the value of the parameter or null if the parameter was not found or if the parameter is a zero-length string.
    • getAttribute

      public static String getAttribute(javax.servlet.http.HttpServletRequest request, String name, boolean emptyStringsOK)
      Returns an attribute as a string.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the parameter you want to get.
      emptyStringsOK - return the parameter values even if it is an empty string.
      Returns:
      the value of the parameter or null if the parameter was not found.
    • getBooleanAttribute

      public static boolean getBooleanAttribute(javax.servlet.http.HttpServletRequest request, String name)
      Returns an attribute as a boolean.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the attribute you want to get.
      Returns:
      true if the value of the attribute is "true", false otherwise.
    • getIntAttribute

      public static int getIntAttribute(javax.servlet.http.HttpServletRequest request, String name, int defaultNum)
      Returns an attribute as a int.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the attribute you want to get.
      defaultNum - the default value if the attribute is not present/cannot be parsed
      Returns:
      the int value of the attribute or the default value if the attribute is not found or is a zero length string.
    • getLongAttribute

      public static long getLongAttribute(javax.servlet.http.HttpServletRequest request, String name, long defaultNum)
      Returns an attribute as a long.
      Parameters:
      request - the HttpServletRequest object, known as "request" in a JSP page.
      name - the name of the attribute you want to get.
      defaultNum - the default value if the attribute is not present/cannot be parsed
      Returns:
      the long value of the attribute or the default value if the attribute is not found or is a zero length string.