Package com.oorian
Class Parameter
java.lang.Object
com.oorian.Parameter
Represents a single HTTP request parameter that may have multiple values.
Parameter encapsulates a named parameter with support for multiple values, which is common in HTML forms with checkboxes or multi-select elements. It provides type-safe accessors for converting values to various primitive types.
Usage:
Parameter param = new Parameter("ids", "1");
param.addValue("2");
param.addValue("3");
List<Integer> ids = param.getValuesAsInts(); // [1, 2, 3]
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a value to this parameter.getName()Returns the parameter name.getValue()Returns the first value of this parameter.Returns the first value as a Boolean.Returns the first value as a Double.Returns the first value as a Float.Returns the first value as an Integer.Returns the first value as a Long.Returns the first value as a Short.Returns all values as strings.Returns all values converted to Booleans.Returns all values converted to Doubles.Returns all values converted to Floats.Returns all values converted to Integers.Returns all values converted to Longs.Returns all values converted to Shorts.toString()Returns a string representation of this parameter.
-
Constructor Details
-
Parameter
Constructs a Parameter with the specified name and no values.- Parameters:
name- the parameter name
-
Parameter
Constructs a Parameter with the specified name and initial value.- Parameters:
name- the parameter namevalue- the initial value
-
-
Method Details
-
addValue
Adds a value to this parameter.- Parameters:
value- the value to add
-
getName
Returns the parameter name.- Returns:
- the name
-
getValues
Returns all values as strings.- Returns:
- list of string values
-
getValuesAsInts
Returns all values converted to Integers.- Returns:
- list of Integer values
- Throws:
NumberFormatException- if any value cannot be parsed
-
getValuesAsLongs
Returns all values converted to Longs.- Returns:
- list of Long values
- Throws:
NumberFormatException- if any value cannot be parsed
-
getValuesAsShorts
Returns all values converted to Shorts.- Returns:
- list of Short values
- Throws:
NumberFormatException- if any value cannot be parsed
-
getValuesAsDoubles
Returns all values converted to Doubles.- Returns:
- list of Double values
- Throws:
NumberFormatException- if any value cannot be parsed
-
getValuesAsFloats
Returns all values converted to Floats.- Returns:
- list of Float values
- Throws:
NumberFormatException- if any value cannot be parsed
-
getValuesAsBooleans
Returns all values converted to Booleans.- Returns:
- list of Boolean values
-
getValue
Returns the first value of this parameter.- Returns:
- the first value, or null if no values exist
-
getValueAsInt
Returns the first value as an Integer.- Returns:
- the Integer value, or null if no values exist
- Throws:
NumberFormatException- if the value cannot be parsed
-
getValueAsLong
Returns the first value as a Long.- Returns:
- the Long value, or null if no values exist
- Throws:
NumberFormatException- if the value cannot be parsed
-
getValueAsShort
Returns the first value as a Short.- Returns:
- the Short value, or null if no values exist
- Throws:
NumberFormatException- if the value cannot be parsed
-
getValueAsDouble
Returns the first value as a Double.- Returns:
- the Double value, or null if no values exist
- Throws:
NumberFormatException- if the value cannot be parsed
-
getValueAsFloat
Returns the first value as a Float.- Returns:
- the Float value, or null if no values exist
- Throws:
NumberFormatException- if the value cannot be parsed
-
getValueAsBoolean
Returns the first value as a Boolean.Uses
Boolean.parseBoolean(String)which returns true only if the value equals "true" (case-insensitive).- Returns:
- the Boolean value, or null if no values exist
-
toString
Returns a string representation of this parameter.The format is:
name=[value1, value2, ...]
-