Package com.oorian

Class Parameters

java.lang.Object
com.oorian.Parameters

public class Parameters extends Object
Collection class for managing HTTP request parameters with type-safe accessors.

Parameters provides a convenient wrapper around request parameters, supporting multi-valued parameters and automatic type conversion. It is used throughout the Oorian framework for handling form submissions, AJAX requests, and file uploads.

Key Features:

  • Multi-valued parameter support
  • Automatic type conversion to Integer, Long, Float, Double, Boolean, etc.
  • Null-safe value retrieval
  • Parameter iteration and inspection

Usage:


 Parameters params = new Parameters(request.getParameterMap());
 Integer userId = params.getParameterValueAsInt("userId");
 List<Long> ids = params.getParameterValuesAsLongs("selectedIds");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Parameters

      public Parameters()
      Constructs an empty Parameters collection.
    • Parameters

      public Parameters(Parameters parameters)
      Constructs a Parameters collection as a copy of another.
      Parameters:
      parameters - the Parameters to copy from
    • Parameters

      public Parameters(String name, String[] values)
      Constructs a Parameters collection with a single multi-valued parameter.
      Parameters:
      name - the parameter name
      values - the parameter values
    • Parameters

      public Parameters(Map<String,String[]> params)
      Constructs a Parameters collection from a parameter map.
      Parameters:
      params - the map of parameter names to value arrays
  • Method Details

    • addParameter

      public final void addParameter(Parameter param)
      Adds a Parameter object to this collection.
      Parameters:
      param - the Parameter to add
    • setParameterValue

      public final void setParameterValue(String name, String value)
      Sets a single-valued parameter, replacing any existing values.
      Parameters:
      name - the parameter name
      value - the parameter value (null values are ignored)
    • addParameterValue

      public final void addParameterValue(String name, String value)
      Adds a value to a parameter, supporting multi-valued parameters.
      Parameters:
      name - the parameter name
      value - the value to add (null values are ignored)
    • addParameter

      public final void addParameter(String name, String[] values)
      Adds multiple values to a parameter from an array.
      Parameters:
      name - the parameter name
      values - the values to add (null arrays are ignored)
    • addParameter

      public final void addParameter(String name, List<String> values)
      Adds multiple values to a parameter from a list.
      Parameters:
      name - the parameter name
      values - the values to add (null lists are ignored)
    • addParameters

      public final void addParameters(Map<String,String[]> params)
      Adds all parameters from a map.
      Parameters:
      params - the map of parameter names to value arrays
    • removeParameter

      public final void removeParameter(String name)
      Removes a parameter from this collection.
      Parameters:
      name - the parameter name to remove
    • containsParameter

      public final boolean containsParameter(String name)
      Checks if a parameter exists in this collection.
      Parameters:
      name - the parameter name
      Returns:
      true if the parameter exists
    • getParameterNames

      public final List<String> getParameterNames()
      Returns a list of all parameter names.
      Returns:
      list of parameter names
    • getParameters

      public final List<Parameter> getParameters()
      Returns a list of all Parameter objects.
      Returns:
      list of Parameter objects
    • getParameter

      public final Parameter getParameter(String name)
      Returns the Parameter object for the specified name.
      Parameters:
      name - the parameter name
      Returns:
      the Parameter, or null if not found
    • getParameterValues

      public final List<String> getParameterValues(String name)
      Returns all values for the specified parameter.
      Parameters:
      name - the parameter name
      Returns:
      list of values, or empty list if not found
    • getParameterValuesAsInts

      public final List<Integer> getParameterValuesAsInts(String name)
      Returns all values for the specified parameter as Integers.

      Values that cannot be parsed as integers are silently skipped.

      Parameters:
      name - the parameter name
      Returns:
      list of Integer values
    • getParameterValuesAsLongs

      public final List<Long> getParameterValuesAsLongs(String name)
      Returns all values for the specified parameter as Longs.

      Values that cannot be parsed as longs are silently skipped.

      Parameters:
      name - the parameter name
      Returns:
      list of Long values
    • getParameterValuesAsShorts

      public final List<Short> getParameterValuesAsShorts(String name)
      Returns all values for the specified parameter as Shorts.

      Values that cannot be parsed as shorts are silently skipped.

      Parameters:
      name - the parameter name
      Returns:
      list of Short values
    • getParameterValuesAsDoubles

      public final List<Double> getParameterValuesAsDoubles(String name)
      Returns all values for the specified parameter as Doubles.

      Values that cannot be parsed as doubles are silently skipped.

      Parameters:
      name - the parameter name
      Returns:
      list of Double values
    • getParameterValuesAsFloats

      public final List<Float> getParameterValuesAsFloats(String name)
      Returns all values for the specified parameter as Floats.

      Values that cannot be parsed as floats are silently skipped.

      Parameters:
      name - the parameter name
      Returns:
      list of Float values
    • getParameterValuesAsBooleans

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

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

      public final Integer getParameterValueAsInt(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
    • getParameterValueAsLong

      public final Long getParameterValueAsLong(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
    • getParameterValueAsShort

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

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

      public final Float getParameterValueAsFloat(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
    • getParameterValueAsBoolean

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

      public boolean isEmpty()
      Checks if this collection contains no parameters.
      Returns:
      true if empty
    • size

      public int size()
      Returns the number of parameters in this collection.
      Returns:
      the parameter count
    • toString

      public String toString()
      Returns a string representation of all parameters.
      Overrides:
      toString in class Object
      Returns:
      formatted string of parameter names and values