net.contextfw.web.application.request
Class RequestParameter

java.lang.Object
  extended by net.contextfw.web.application.request.RequestParameter

public class RequestParameter
extends Object

Provides functionality to access on GET/POST-parameter.

Parsing integers, floats and booleans

Integers, floats and booleans can be represented as a string in many ways. For instance decimal point can be '.' or ','. Also other means of representation are possible, i.e. scientific form

Therefore it is the implentors responsibility to decide what kind of representations are accepted.

Author:
Marko Lavikainen

Constructor Summary
RequestParameter(String name, String publicName, javax.servlet.http.HttpServletRequest request)
           Constructs new HiveParameter This constructor should not be called explicitly.
 
Method Summary
 void clearOptions()
           
 void clearValues()
           
 Boolean getBooleanValue()
           Returns parameter value as a boolean.
 Boolean getBooleanValue(Boolean def)
           Returns parameter value as a boolean.
 Boolean[] getBooleanValues()
           Returns all parameter values in a table of floats Booleans are parsed simply using Boolean.parseBoolean().
 Boolean[] getBooleanValues(Boolean[] def)
           
 Double getDoubleValue()
           Returns parameter value as a double.
 Double getDoubleValue(Double def)
           Returns parameter value as a double.
 Double[] getDoubleValues()
           Returns all parameter values in a table of doubles When doubles are handled, system accepts both ways to represent decimal points.
 Double[] getDoubleValues(Double[] def)
           Returns all parameter values in a table of doubles When doubles are handled, system accepts both ways to represent decimal points.
 Float getFloatValue()
           Returns parameter value as a float.
 Float getFloatValue(Float def)
           Returns parameter value as a long.
 Float[] getFloatValues()
           Returns all parameter values in a table of floats When floats are handled, system accepts both ways to represent decimal points.
 Float[] getFloatValues(Float[] def)
           
 Integer getIntValue()
           Returns parameter value as an integer.
 Integer getIntValue(Integer def)
           Returns parameter value as an integer.
 Integer[] getIntValues()
           Returns all parameter values in a table of integers
 Integer[] getIntValues(Integer[] def)
           
 Long getLongValue()
           Returns parameter value as a long integer.
 Long getLongValue(Long def)
           Returns parameter value as a long.
 Long[] getLongValues()
           Returns all parameter values in a table of long integers
 Long[] getLongValues(Long[] def)
           
 Object getModifier()
           
 String getName()
           
 Object getOptions()
           
 int getStatus()
           
 String getStringValue()
           Returns parameter value as a string.
 String getStringValue(String def)
           Returns parameter value as a string.
 String[] getStringValues()
           Returns all parameter values in a table of strings
 String[] getStringValues(String[] def)
           Returns all parameter values in a table of strings
 boolean hasValue()
           
 boolean hasValue(boolean strict)
           
 String publicName()
           
 void setModifier(Object modifier)
           
 void setOptions(Object options)
           
 void setPublicName(String name)
           
 void setStatus(int status)
           
 void setValue(boolean value)
           
 void setValue(double value)
           
 void setValue(float value)
           
 void setValue(int value)
           
 void setValue(long value)
           
 void setValue(String value)
           
 void setValues(boolean[] values)
           
 void setValues(double[] values)
           
 void setValues(float[] values)
           
 void setValues(int[] values)
           
 void setValues(long[] values)
           
 void setValues(String[] values)
           
 int valueCount()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestParameter

public RequestParameter(String name,
                        String publicName,
                        javax.servlet.http.HttpServletRequest request)

Constructs new HiveParameter

This constructor should not be called explicitly.

Parameters:
name - Parameter name, which corresponds to the equal GET/POST-value(s).
Method Detail

valueCount

public int valueCount()

getStringValue

public String getStringValue()

Returns parameter value as a string.

If parameter has multiple values, then only the first value is returned.

Returns:
Found parameter value.

getStringValue

public String getStringValue(String def)

Returns parameter value as a string.

If parameter has multiple values, then only the first value is returned.

Parameters:
def - Default value. Can be null.
Returns:
Found parameter value. If value does not exists or request is ignored, then default value is returned.

getStringValues

public String[] getStringValues()

Returns all parameter values in a table of strings

Returns:
Found parameter values.
Throws:
NoValueException - Thrown if parameter has no value(s), or request is ignored.

getStringValues

public String[] getStringValues(String[] def)

Returns all parameter values in a table of strings

Parameters:
def - Default values
Returns:
Found parameter values. If parameter does not have any values, or request is ignored, then default values are returned.

getIntValue

public Integer getIntValue()
                    throws NumberFormatException

Returns parameter value as an integer.

If parameter has multiple values, then only the first value is returned.

Returns:
Found parameter value
Throws:
NumberFormatException - Thrown if parameter cannot be parsed to integer.

getIntValue

public Integer getIntValue(Integer def)

Returns parameter value as an integer.

If parameter has multiple values, then only the first value is returned.

Parameters:
def - Default value
Returns:
Found parameter value. If parameter does not have any values, or if request is ignored, then default value are returned.

getLongValue

public Long getLongValue()
                  throws NumberFormatException

Returns parameter value as a long integer.

If parameter has multiple values, then only the first value is returned.

Returns:
Found parameter value
Throws:
NumberFormatException - Thrown if parameter cannot be parsed to long integer.

getLongValue

public Long getLongValue(Long def)

Returns parameter value as a long.

If parameter has multiple values, then only the first value is returned.

Parameters:
def - Default value
Returns:
Found parameter value. If parameter does not have any values, or if request is ignored, then default value are returned.

getLongValues

public Long[] getLongValues()
                     throws NumberFormatException

Returns all parameter values in a table of long integers

Returns:
Found parameter values
Throws:
NoValueException - Thrown if parameter has no value(s), or if request is ignored.
NumberFormatException - Thrown if any of the parameter values cannot be parsed to long integer

getLongValues

public Long[] getLongValues(Long[] def)

getIntValues

public Integer[] getIntValues()
                       throws NumberFormatException

Returns all parameter values in a table of integers

Returns:
Found parameter values
Throws:
NumberFormatException - Thrown if any of the parameter values cannot be parsed to int

getIntValues

public Integer[] getIntValues(Integer[] def)

getFloatValue

public Float getFloatValue()
                    throws NumberFormatException

Returns parameter value as a float.

If parameter has multiple values, then only the first value is returned.

When floats are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Returns:
Found parameter value
Throws:
NumberFormatException - Thrown if parameter cannot be parsed to float.

getFloatValue

public Float getFloatValue(Float def)

Returns parameter value as a long.

If parameter has multiple values, then only the first value is returned.

When floats are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Parameters:
def - Default value
Returns:
Found parameter value. If parameter does not have any values, or if request is ignored, then default value are returned.

getFloatValues

public Float[] getFloatValues()
                       throws NumberFormatException

Returns all parameter values in a table of floats

When floats are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Returns:
Found parameter values
Throws:
NumberFormatException - Thrown if any of the parameter values cannot be parsed to float.

getFloatValues

public Float[] getFloatValues(Float[] def)

getDoubleValue

public Double getDoubleValue()
                      throws NumberFormatException

Returns parameter value as a double.

If parameter has multiple values, then only the first value is returned.

When doubles are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Returns:
Found parameter value
Throws:
NumberFormatException - Thrown if parameter cannot be parsed to double.

getDoubleValue

public Double getDoubleValue(Double def)

Returns parameter value as a double.

If parameter has multiple values, then only the first value is returned.

When doubles are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Parameters:
def - Default value
Returns:
Found parameter value. If parameter does not have any values, or if request is ignored, then default value are returned.

getDoubleValues

public Double[] getDoubleValues()
                         throws NumberFormatException

Returns all parameter values in a table of doubles

When doubles are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Returns:
Found parameter values
Throws:
NumberFormatException - Thrown if any of the parameter values cannot be parsed to doubles.

getDoubleValues

public Double[] getDoubleValues(Double[] def)

Returns all parameter values in a table of doubles

When doubles are handled, system accepts both ways to represent decimal points. This means, that decimal point can be represented with '.' or ','. For example "123.435" or "123,345" are both accepted.

Returns:
Found parameter values
Throws:
NumberFormatException - Thrown if any of the parameter values cannot be parsed to doubles.

getBooleanValue

public Boolean getBooleanValue()

Returns parameter value as a boolean.

If parameter has multiple values, then only the first value is returned.

Booleans are parsed simply using Boolean.parseBoolean(). Refer J2SE-documentation for more information.

Returns:
Found parameter value
Throws:
NoValueException - Thrown if parameter has no value, or if request is ignored.

getBooleanValue

public Boolean getBooleanValue(Boolean def)

Returns parameter value as a boolean.

If parameter has multiple values, then only the first value is returned.

Booleans are parsed simply using Boolean.parseBoolean(). Refer J2SE-documentation for more information.

Parameters:
def - Default value
Returns:
Found parameter value. If parameter does not have any values, or if request is ignored, then default value are returned.

getBooleanValues

public Boolean[] getBooleanValues()

Returns all parameter values in a table of floats

Booleans are parsed simply using Boolean.parseBoolean(). Refer J2SE-documentation for more information.

Returns:
Found parameter values
Throws:
NoValueException - Thrown if parameter has no value(s), or if request is ignored.

getBooleanValues

public Boolean[] getBooleanValues(Boolean[] def)

hasValue

public boolean hasValue(boolean strict)

hasValue

public boolean hasValue()

getName

public String getName()

setPublicName

public void setPublicName(String name)

setValue

public void setValue(String value)

setValues

public void setValues(String[] values)

setValue

public void setValue(int value)

setValues

public void setValues(int[] values)

setValue

public void setValue(long value)

setValues

public void setValues(long[] values)

setValue

public void setValue(float value)

setValues

public void setValues(float[] values)

setValue

public void setValue(double value)

setValues

public void setValues(double[] values)

setValue

public void setValue(boolean value)

setValues

public void setValues(boolean[] values)

clearValues

public void clearValues()

clearOptions

public void clearOptions()

getOptions

public Object getOptions()

setOptions

public void setOptions(Object options)

getStatus

public int getStatus()

setStatus

public void setStatus(int status)

publicName

public String publicName()

getModifier

public Object getModifier()

setModifier

public void setModifier(Object modifier)


Copyright © 2011. All Rights Reserved.