Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.webchat.util
Class ParamUtils

java.lang.Object
  extended by com.jivesoftware.webchat.util.ParamUtils

public class ParamUtils
extends java.lang.Object

A utility class to handle servlet parameters.


Constructor Summary
ParamUtils()
           
 
Method Summary
static java.lang.String getAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Gets a parameter as a string.
static java.lang.String getAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, boolean emptyStringsOK)
          Gets a parameter as a string.
static boolean getBooleanAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Gets an attribute as a boolean.
static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Gets a parameter as a boolean.
static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, boolean defaultVal)
          Gets a parameter as a boolean.
static double getDoubleParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, double defaultNum)
          Gets a parameter as a double.
static int getIntAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultNum)
          Gets an attribute as a int.
static int getIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultNum)
          Gets a parameter as an int.
static int[] getIntParameters(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultNum)
          Gets a list of int parameters.
static long getLongAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, long defaultNum)
          Gets an attribute as a long.
static long getLongParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, long defaultNum)
          Gets a parameter as a long.
static long[] getLongParameters(javax.servlet.http.HttpServletRequest request, java.lang.String name, long defaultNum)
          Gets a list of long parameters.
static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Returns a parameter as a string or null if the parameter doesn't exist or is an empty string.
static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, boolean emptyStringsOK)
          Returns a paramter as a string or null if the parameter doesn't exist.
static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String defaultValue)
          Returns a paramter as a string or the default value if the paramter doesn't exist or is an empty string.
static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String defaultValue, boolean emptyStringsOK)
          Returns a paramter as a string or the specified default value if the parameter doesn't exist.
static java.lang.String[] getParameters(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Returns a list of parameters of the same name
static java.lang.String getPathToPage(javax.servlet.http.HttpServletRequest request)
          Returns the path to the requested page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParamUtils

public ParamUtils()
Method Detail

getParameter

public static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name)
Returns a parameter as a string or null if the parameter doesn't exist or is an empty string.

Parameters:
request - the HTTP request.
name - the name of the paramter.
Returns:
the parameter value or null if the parameter doesn't exist or is an empty string.

getParameter

public static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name,
                                            java.lang.String defaultValue)
Returns a paramter as a string or the default value if the paramter doesn't exist or is an empty string.

Parameters:
request - the HTTP request.
name - the name of the parameter.
defaultValue - the value to return if the paramter was not found or was an empty string.
Returns:
a paramter as a string or the default value if the paramter doesn't exist or is an empty string.

getParameter

public static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name,
                                            boolean emptyStringsOK)
Returns a paramter as a string or null if the parameter doesn't exist. This method will also return null if the emptyStringsOK parameter is false. If that parameter is set to true then an empty string will be returned if that is the value of the parameter.

Parameters:
request - the HTTP request.
name - the name of the parameter.
emptyStringsOK - true if parameters with the value "" are acceptable, false if not.
Returns:
the parameter value or null if it was not found. This will also return null if the value is "" and emptyStringsOK is set to false.

getParameter

public static java.lang.String getParameter(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name,
                                            java.lang.String defaultValue,
                                            boolean emptyStringsOK)
Returns a paramter as a string or the specified default value if the parameter doesn't exist. This method will also return the default value if the emptyStringsOK parameter is false. If that parameter is set to true then an empty string will be returned if that is the value of the parameter.

Parameters:
request - the HTTP request.
name - the name of the parameter.
defaultValue - the default value of the parameter if it was not found and if the value is "" and the emptyStringsOK paramter is false.
emptyStringsOK - true if parameters with the value "" are acceptable, false if not.
Returns:
the parameter value or the defaultValue if it was not found. This will also return the default value if the value is "" and emptyStringsOK is set to false.

getParameters

public static java.lang.String[] getParameters(javax.servlet.http.HttpServletRequest request,
                                               java.lang.String name)
Returns a list of parameters of the same name

Parameters:
request - an HttpServletRequest object.
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.

getBooleanParameter

public static boolean getBooleanParameter(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String name)
Gets 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,
                                          java.lang.String name,
                                          boolean defaultVal)
Gets 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.

getIntParameter

public static int getIntParameter(javax.servlet.http.HttpServletRequest request,
                                  java.lang.String name,
                                  int defaultNum)
Gets 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
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,
                                     java.lang.String name,
                                     int defaultNum)
Gets 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.

getDoubleParameter

public static double getDoubleParameter(javax.servlet.http.HttpServletRequest request,
                                        java.lang.String name,
                                        double defaultNum)
Gets 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
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,
                                    java.lang.String name,
                                    long defaultNum)
Gets 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
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,
                                       java.lang.String name,
                                       long defaultNum)
Gets 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.

getAttribute

public static java.lang.String getAttribute(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name)
Gets 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.

getAttribute

public static java.lang.String getAttribute(javax.servlet.http.HttpServletRequest request,
                                            java.lang.String name,
                                            boolean emptyStringsOK)
Gets 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.

getBooleanAttribute

public static boolean getBooleanAttribute(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String name)
Gets 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,
                                  java.lang.String name,
                                  int defaultNum)
Gets 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
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,
                                    java.lang.String name,
                                    long defaultNum)
Gets 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
Returns:
The long value of the attribute or the default value if the attribute is not found or is a zero length string.

getPathToPage

public static java.lang.String getPathToPage(javax.servlet.http.HttpServletRequest request)
Returns the path to the requested page. For example, if the requested page is www.jivesoftware.com/admin/internal/test.jsp, the returned path will be /admin/internal/

Parameters:
request - The HttpServletRequest instance, known as "request" in a JSP page.
Returns:
the path to the page.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.