Package com.oorian
Class Parameters
java.lang.Object
com.oorian.Parameters
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 Summary
ConstructorsConstructorDescriptionConstructs an empty Parameters collection.Parameters(Parameters parameters) Constructs a Parameters collection as a copy of another.Parameters(String name, String[] values) Constructs a Parameters collection with a single multi-valued parameter.Parameters(Map<String, String[]> params) Constructs a Parameters collection from a parameter map. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddParameter(Parameter param) Adds a Parameter object to this collection.final voidaddParameter(String name, String[] values) Adds multiple values to a parameter from an array.final voidaddParameter(String name, List<String> values) Adds multiple values to a parameter from a list.final voidaddParameters(Map<String, String[]> params) Adds all parameters from a map.final voidaddParameterValue(String name, String value) Adds a value to a parameter, supporting multi-valued parameters.final booleancontainsParameter(String name) Checks if a parameter exists in this collection.final ParametergetParameter(String name) Returns the Parameter object for the specified name.Returns a list of all parameter names.Returns a list of all Parameter objects.final StringgetParameterValue(String name) Returns the first value of the specified parameter.final BooleanReturns the first value of the specified parameter as a Boolean.final DoubleReturns the first value of the specified parameter as a Double.final FloatReturns the first value of the specified parameter as a Float.final IntegergetParameterValueAsInt(String name) Returns the first value of the specified parameter as an Integer.final LongReturns the first value of the specified parameter as a Long.final ShortReturns the first value of the specified parameter as a Short.getParameterValues(String name) Returns all values for the specified parameter.Returns all values for the specified parameter as Booleans.Returns all values for the specified parameter as Doubles.Returns all values for the specified parameter as Floats.Returns all values for the specified parameter as Integers.Returns all values for the specified parameter as Longs.Returns all values for the specified parameter as Shorts.booleanisEmpty()Checks if this collection contains no parameters.final voidremoveParameter(String name) Removes a parameter from this collection.final voidsetParameterValue(String name, String value) Sets a single-valued parameter, replacing any existing values.intsize()Returns the number of parameters in this collection.toString()Returns a string representation of all parameters.
-
Constructor Details
-
Parameters
public Parameters()Constructs an empty Parameters collection. -
Parameters
Constructs a Parameters collection as a copy of another.- Parameters:
parameters- the Parameters to copy from
-
Parameters
Constructs a Parameters collection with a single multi-valued parameter.- Parameters:
name- the parameter namevalues- the parameter values
-
Parameters
Constructs a Parameters collection from a parameter map.- Parameters:
params- the map of parameter names to value arrays
-
-
Method Details
-
addParameter
Adds a Parameter object to this collection.- Parameters:
param- the Parameter to add
-
setParameterValue
Sets a single-valued parameter, replacing any existing values.- Parameters:
name- the parameter namevalue- the parameter value (null values are ignored)
-
addParameterValue
Adds a value to a parameter, supporting multi-valued parameters.- Parameters:
name- the parameter namevalue- the value to add (null values are ignored)
-
addParameter
Adds multiple values to a parameter from an array.- Parameters:
name- the parameter namevalues- the values to add (null arrays are ignored)
-
addParameter
Adds multiple values to a parameter from a list.- Parameters:
name- the parameter namevalues- the values to add (null lists are ignored)
-
addParameters
Adds all parameters from a map.- Parameters:
params- the map of parameter names to value arrays
-
removeParameter
Removes a parameter from this collection.- Parameters:
name- the parameter name to remove
-
containsParameter
Checks if a parameter exists in this collection.- Parameters:
name- the parameter name- Returns:
- true if the parameter exists
-
getParameterNames
Returns a list of all parameter names.- Returns:
- list of parameter names
-
getParameters
Returns a list of all Parameter objects.- Returns:
- list of Parameter objects
-
getParameter
Returns the Parameter object for the specified name.- Parameters:
name- the parameter name- Returns:
- the Parameter, or null if not found
-
getParameterValues
Returns all values for the specified parameter.- Parameters:
name- the parameter name- Returns:
- list of values, or empty list if not found
-
getParameterValuesAsInts
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
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
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
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
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
Returns all values for the specified parameter as Booleans.- Parameters:
name- the parameter name- Returns:
- list of Boolean values
-
getParameterValue
Returns the first value of the specified parameter.- Parameters:
name- the parameter name- Returns:
- the first value, or null if not found
-
getParameterValueAsInt
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
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
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
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
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
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
Returns a string representation of all parameters.
-