Package com.oorian

Class RequestParameters

java.lang.Object
com.oorian.RequestParameters
All Implemented Interfaces:
Serializable

public class RequestParameters extends Object implements Serializable
Serializable wrapper for HTTP request parameters.

RequestParameters captures the parameter map from an HttpServletRequest at construction time, allowing the parameters to be accessed after the original request has been completed. This is essential for asynchronous processing and worker thread operations.

Key Features:

  • Serializable for session persistence and clustering
  • Type-safe accessors for Integer, Long, Float, and Boolean values
  • Support for multi-valued parameters
  • Default value support for missing parameters

Usage:


 RequestParameters params = new RequestParameters(request);
 Integer userId = params.getParameterAsInt("userId");
 String action = params.getParameter("action", "default");
 List<Long> selectedIds = params.getParameterValuesAsLong("ids");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Method Details

    • getParameterNames

      public String[] getParameterNames()
      Returns an array of all parameter names.
      Returns:
      array of parameter names
    • getParameterValues

      public String[] getParameterValues(String name)
      Returns all values for the specified parameter.
      Parameters:
      name - the parameter name
      Returns:
      array of values, or null if the parameter does not exist
    • getParameter

      public String getParameter(String name)
      Returns the first value of the specified parameter.
      Parameters:
      name - the parameter name
      Returns:
      the first value, or null if the parameter does not exist
    • getParameter

      public String getParameter(String name, String defaultValue)
      Returns the first value of the specified parameter, or a default if not found.
      Parameters:
      name - the parameter name
      defaultValue - the value to return if the parameter does not exist
      Returns:
      the parameter value, or the default value
    • getParameterAsInt

      public final Integer getParameterAsInt(String name)
      Returns the first value of the specified parameter as an Integer.
      Parameters:
      name - the parameter name
      Returns:
      the Integer value, or null if not found or not parseable
    • getParameterAsInt

      public final Integer getParameterAsInt(String name, int defaultValue)
      Returns the first value of the specified parameter as an Integer, or a default.
      Parameters:
      name - the parameter name
      defaultValue - the value to return if the parameter is not found or not parseable
      Returns:
      the Integer value, or the default value
    • getParameterAsLong

      public final Long getParameterAsLong(String name)
      Returns the first value of the specified parameter as a Long.
      Parameters:
      name - the parameter name
      Returns:
      the Long value, or null if not found or not parseable
    • getParameterAsLong

      public final Long getParameterAsLong(String name, long defaultValue)
      Returns the first value of the specified parameter as a Long, or a default.
      Parameters:
      name - the parameter name
      defaultValue - the value to return if the parameter is not found or not parseable
      Returns:
      the Long value, or the default value
    • getParameterAsFloat

      public final Float getParameterAsFloat(String name)
      Returns the first value of the specified parameter as a Float.
      Parameters:
      name - the parameter name
      Returns:
      the Float value, or null if not found or not parseable
    • getParameterAsFloat

      public final Float getParameterAsFloat(String name, float defaultValue)
      Returns the first value of the specified parameter as a Float, or a default.
      Parameters:
      name - the parameter name
      defaultValue - the value to return if the parameter is not found or not parseable
      Returns:
      the Float value, or the default value
    • getParameterAsBoolean

      public final Boolean getParameterAsBoolean(String name)
      Returns the first value of the specified parameter as a Boolean.
      Parameters:
      name - the parameter name
      Returns:
      the Boolean value, or null if not found
    • getParameterAsBoolean

      public final Boolean getParameterAsBoolean(String name, boolean defaultValue)
      Returns the first value of the specified parameter as a Boolean, or a default.
      Parameters:
      name - the parameter name
      defaultValue - the value to return if the parameter is not found
      Returns:
      the Boolean value, or the default value
    • getParameterValuesAsString

      public final List<String> getParameterValuesAsString(String name)
      Returns all values for the specified parameter as a list of Strings.
      Parameters:
      name - the parameter name
      Returns:
      list of String values, or an empty list if not found
    • getParameterValuesAsInt

      public final List<Integer> getParameterValuesAsInt(String name)
      Returns all values for the specified parameter as a list of Integers.
      Parameters:
      name - the parameter name
      Returns:
      list of Integer values
      Throws:
      NumberFormatException - if any value cannot be parsed
    • getParameterValuesAsShort

      public final List<Short> getParameterValuesAsShort(String name)
      Returns all values for the specified parameter as a list of Shorts.
      Parameters:
      name - the parameter name
      Returns:
      list of Short values
      Throws:
      NumberFormatException - if any value cannot be parsed
    • getParameterValuesAsLong

      public final List<Long> getParameterValuesAsLong(String name)
      Returns all values for the specified parameter as a list of Longs.
      Parameters:
      name - the parameter name
      Returns:
      list of Long values
      Throws:
      NumberFormatException - if any value cannot be parsed
    • getParameterValuesAsFloat

      public final List<Float> getParameterValuesAsFloat(String name)
      Returns all values for the specified parameter as a list of Floats.
      Parameters:
      name - the parameter name
      Returns:
      list of Float values
      Throws:
      NumberFormatException - if any value cannot be parsed
    • getParameterValuesAsBoolean

      public final List<Boolean> getParameterValuesAsBoolean(String name)
      Returns all values for the specified parameter as a list of Booleans.
      Parameters:
      name - the parameter name
      Returns:
      list of Boolean values