org.apache.turbine.util.parser
Class BaseValueParser

java.lang.Object
  extended byorg.apache.turbine.util.pool.RecyclableSupport
      extended byorg.apache.turbine.util.parser.BaseValueParser
All Implemented Interfaces:
Recyclable, ValueParser
Direct Known Subclasses:
DefaultCookieParser, DefaultParameterParser

public class BaseValueParser
extends RecyclableSupport
implements ValueParser

BaseValueParser is a base class for classes that need to parse name/value Parameters, for example GET/POST data or Cookies (DefaultParameterParser and DefaultCookieParser).

It can also be used standalone, for an example see DataStreamParser.

NOTE: The name= portion of a name=value pair may be converted to lowercase or uppercase when the object is initialized and when new data is added. This behaviour is determined by the url.case.folding property in TurbineResources.properties. Adding a name/value pair may overwrite existing name=value pairs if the names match:

 ValueParser vp = new BaseValueParser();
 vp.add("ERROR",1);
 vp.add("eRrOr",2);
 int result = vp.getInt("ERROR");
 
In the above example, result is 2.

Version:
$Id: BaseValueParser.java 646751 2008-04-10 10:55:06Z tv $
Author:
Ilkka Priha, Jon S. Stevens, Sean Legassick, Jason van Zyl, Scott Eade, Henning P. Schmiedehausen, Quinton McCombs

Field Summary
 
Fields inherited from interface org.apache.turbine.util.parser.ValueParser
URL_CASE_FOLDING, URL_CASE_FOLDING_LOWER, URL_CASE_FOLDING_NONE, URL_CASE_FOLDING_UPPER
 
Constructor Summary
BaseValueParser()
          Default constructor
BaseValueParser(java.lang.String characterEncoding)
          Constructor that takes a character encoding
BaseValueParser(java.lang.String characterEncoding, java.util.Locale locale)
          Constructor that takes a character encoding and a locale
 
Method Summary
 void add(java.lang.String name, double value)
          Add a name/value pair into this object.
 void add(java.lang.String name, int value)
          Add a name/value pair into this object.
 void add(java.lang.String name, java.lang.Integer value)
          Add a name/value pair into this object.
 void add(java.lang.String name, long value)
          Add a name/value pair into this object.
 void add(java.lang.String name, java.lang.String value)
          Add a name/value pair into this object.
 void add(java.lang.String name, java.lang.String[] value)
          Add an array of Strings for a key.
 void append(java.lang.String name, java.lang.String value)
          Deprecated. Use add(name, value) instead.
 void clear()
          Clear all name/value pairs out of this object.
 boolean containsDateSelectorKeys(java.lang.String key)
          Check for existence of key_day, key_month and key_year parameters (as returned by DateSelector generated HTML).
 boolean containsKey(java.lang.Object key)
          Determine whether a given key has been inserted.
 boolean containsTimeSelectorKeys(java.lang.String key)
          Check for existence of key_hour, key_minute and key_second parameters (as returned by TimeSelector generated HTML).
 java.lang.String convert(java.lang.String value)
          Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING.
static java.lang.String convertAndTrim(java.lang.String value)
          Deprecated. Use ParserUtils.convertAndTrim(value).
 void dispose()
          Disposes the parser.
 java.lang.String get(java.lang.String name)
          Return a String for the given name.
 java.math.BigDecimal getBigDecimal(java.lang.String name)
          Return a BigDecimal for the given name.
 java.math.BigDecimal getBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
          Return a BigDecimal for the given name.
 java.math.BigDecimal[] getBigDecimals(java.lang.String name)
          Return an array of BigDecimals for the given name.
 java.lang.Boolean getBool(java.lang.String name)
          Deprecated. use getBooleanObject(String) instead
 java.lang.Boolean getBool(java.lang.String name, boolean defaultValue)
          Deprecated. use getBooleanObject(java.lang.String) instead
 boolean getBoolean(java.lang.String name)
          Return a boolean for the given name.
 boolean getBoolean(java.lang.String name, boolean defaultValue)
          Return a boolean for the given name.
 java.lang.Boolean getBooleanObject(java.lang.String name)
          Returns a Boolean object for the given name.
 java.lang.Boolean getBooleanObject(java.lang.String name, java.lang.Boolean defaultValue)
          Returns a Boolean object for the given name.
 java.lang.Boolean[] getBooleanObjects(java.lang.String name)
          Return an array of Booleans for the given name.
 boolean[] getBooleans(java.lang.String name)
          Return an array of booleans for the given name.
 byte getByte(java.lang.String name)
          Return a byte for the given name.
 byte getByte(java.lang.String name, byte defaultValue)
          Return a byte for the given name.
 java.lang.Byte getByteObject(java.lang.String name)
          Return a byte for the given name.
 java.lang.Byte getByteObject(java.lang.String name, java.lang.Byte defaultValue)
          Return a byte for the given name.
 byte[] getBytes(java.lang.String name)
          Return an array of bytes for the given name.
 java.lang.String getCharacterEncoding()
          Get the character encoding that will be used by this ValueParser.
 java.util.Date getDate(java.lang.String name)
          Returns a Date object.
 java.util.Date getDate(java.lang.String name, java.text.DateFormat df)
          Returns a Date object.
 java.util.Date getDate(java.lang.String name, java.text.DateFormat df, java.util.Date defaultValue)
          Returns a Date object.
 java.text.DateFormat getDateFormat()
          Get the date format that will be used by this ValueParser.
 double getDouble(java.lang.String name)
          Return a double for the given name.
 double getDouble(java.lang.String name, double defaultValue)
          Return a double for the given name.
 java.lang.Double getDoubleObject(java.lang.String name)
          Return a Double for the given name.
 java.lang.Double getDoubleObject(java.lang.String name, java.lang.Double defaultValue)
          Return a Double for the given name.
 java.lang.Double[] getDoubleObjects(java.lang.String name)
          Return an array of doubles for the given name.
 double[] getDoubles(java.lang.String name)
          Return an array of doubles for the given name.
 float getFloat(java.lang.String name)
          Return a float for the given name.
 float getFloat(java.lang.String name, float defaultValue)
          Return a float for the given name.
 java.lang.Float getFloatObject(java.lang.String name)
          Return a float for the given name.
 java.lang.Float getFloatObject(java.lang.String name, java.lang.Float defaultValue)
          Return a Float for the given name.
 java.lang.Float[] getFloatObjects(java.lang.String name)
          Return an array of floats for the given name.
 float[] getFloats(java.lang.String name)
          Return an array of floats for the given name.
 int getInt(java.lang.String name)
          Return an int for the given name.
 int getInt(java.lang.String name, int defaultValue)
          Return an int for the given name.
 java.lang.Integer getInteger(java.lang.String name)
          Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead
 java.lang.Integer getInteger(java.lang.String name, int defaultValue)
          Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead
 java.lang.Integer getInteger(java.lang.String name, java.lang.Integer def)
          Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead
 java.lang.Integer[] getIntegers(java.lang.String name)
          Deprecated. use getIntObjects(java.lang.String) instead
 java.lang.Integer getIntObject(java.lang.String name)
          Return an Integer for the given name.
 java.lang.Integer getIntObject(java.lang.String name, java.lang.Integer defaultValue)
          Return an Integer for the given name.
 java.lang.Integer[] getIntObjects(java.lang.String name)
          Return an array of Integers for the given name.
 int[] getInts(java.lang.String name)
          Return an array of ints for the given name.
 java.lang.Object[] getKeys()
          Returns all the available parameter names.
 java.util.Locale getLocale()
          Get the locale that will be used by this ValueParser.
 long getLong(java.lang.String name)
          Return a long for the given name.
 long getLong(java.lang.String name, long defaultValue)
          Return a long for the given name.
 java.lang.Long getLongObject(java.lang.String name)
          Return a Long for the given name.
 java.lang.Long getLongObject(java.lang.String name, java.lang.Long defaultValue)
          Return a Long for the given name.
 java.lang.Long[] getLongObjects(java.lang.String name)
          Return an array of Longs for the given name.
 long[] getLongs(java.lang.String name)
          Return an array of longs for the given name.
 java.text.NumberFormat getNumberFormat()
          Get the number format that will be used by this ValueParser.
 org.apache.torque.om.NumberKey getNumberKey(java.lang.String name)
          Deprecated. no replacement
 java.lang.Object getObject(java.lang.String name)
          Return an Object for the given name.
 java.lang.Object[] getObjects(java.lang.String name)
          Return an array of Objects for the given name.
protected  java.lang.String[] getParam(java.lang.String name)
          fetches a key from the parameters map.
 java.lang.String getString(java.lang.String name)
          Return a String for the given name.
 java.lang.String getString(java.lang.String name, java.lang.String defaultValue)
          Return a String for the given name.
 org.apache.torque.om.StringKey getStringKey(java.lang.String name)
          Deprecated. no replacement
 java.lang.String[] getStrings(java.lang.String name)
          Return an array of Strings for the given name.
 java.lang.String[] getStrings(java.lang.String name, java.lang.String[] defaultValue)
          Return an array of Strings for the given name.
protected  java.lang.Object[] getToStringParam(java.lang.String name)
          This method is only used in toString() and can be used by derived classes to add their local parameters to the toString()
 java.util.Enumeration keys()
          Deprecated. use keySet() instead.
 java.util.Set keySet()
          Gets the set of keys
protected  void putParam(java.lang.String name, java.lang.String[] value)
          Puts a key into the parameters map.
 void recycle(java.lang.String characterEncoding)
          Recycles the parser with a character encoding.
 java.lang.Object remove(java.lang.String name)
          Removes the named parameter from the contained hashtable.
 void setCharacterEncoding(java.lang.String s)
          Set the character encoding that will be used by this ValueParser.
 void setDateFormat(java.text.DateFormat df)
          Set the date format that will be used by this ValueParser.
 void setLocale(java.util.Locale l)
          Set the locale that will be used by this ValueParser.
 void setNumberFormat(java.text.NumberFormat nf)
          Set the number format that will be used by this ValueParser.
 void setProperties(java.lang.Object bean)
          Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for.
protected  void setProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop)
          Set the property 'prop' in the bean to the value of the corresponding parameters.
 void setString(java.lang.String name, java.lang.String value)
          Set a parameter to a specific value.
 void setStrings(java.lang.String name, java.lang.String[] values)
          Set a parameter to a specific value.
 java.lang.String toString()
          Simple method that attempts to get a textual representation of this object's name/value pairs.
 
Methods inherited from class org.apache.turbine.util.pool.RecyclableSupport
doDispose, isDisposed, Recyclable, recycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseValueParser

public BaseValueParser()
Default constructor


BaseValueParser

public BaseValueParser(java.lang.String characterEncoding)
Constructor that takes a character encoding


BaseValueParser

public BaseValueParser(java.lang.String characterEncoding,
                       java.util.Locale locale)
Constructor that takes a character encoding and a locale

Method Detail

convertAndTrim

public static java.lang.String convertAndTrim(java.lang.String value)
Deprecated. Use ParserUtils.convertAndTrim(value).

A static version of the convert method, which trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING. It returns a new string so that it does not destroy the value data.

Parameters:
value - A String to be processed.
Returns:
A new String converted to lowercase and trimmed.

recycle

public void recycle(java.lang.String characterEncoding)
Recycles the parser with a character encoding.

Parameters:
characterEncoding - the character encoding.

dispose

public void dispose()
Disposes the parser.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class RecyclableSupport

clear

public void clear()
Clear all name/value pairs out of this object.

Specified by:
clear in interface ValueParser

setCharacterEncoding

public void setCharacterEncoding(java.lang.String s)
Set the character encoding that will be used by this ValueParser.

Specified by:
setCharacterEncoding in interface ValueParser

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Get the character encoding that will be used by this ValueParser.

Specified by:
getCharacterEncoding in interface ValueParser

setLocale

public void setLocale(java.util.Locale l)
Set the locale that will be used by this ValueParser.

Specified by:
setLocale in interface ValueParser

getLocale

public java.util.Locale getLocale()
Get the locale that will be used by this ValueParser.

Specified by:
getLocale in interface ValueParser

setDateFormat

public void setDateFormat(java.text.DateFormat df)
Set the date format that will be used by this ValueParser.

Specified by:
setDateFormat in interface ValueParser

getDateFormat

public java.text.DateFormat getDateFormat()
Get the date format that will be used by this ValueParser.

Specified by:
getDateFormat in interface ValueParser

setNumberFormat

public void setNumberFormat(java.text.NumberFormat nf)
Set the number format that will be used by this ValueParser.

Specified by:
setNumberFormat in interface ValueParser

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Get the number format that will be used by this ValueParser.

Specified by:
getNumberFormat in interface ValueParser

add

public void add(java.lang.String name,
                double value)
Add a name/value pair into this object.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - A double with the value.

add

public void add(java.lang.String name,
                int value)
Add a name/value pair into this object.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - An int with the value.

add

public void add(java.lang.String name,
                java.lang.Integer value)
Add a name/value pair into this object.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - An Integer with the value.

add

public void add(java.lang.String name,
                long value)
Add a name/value pair into this object.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - A long with the value.

add

public void add(java.lang.String name,
                java.lang.String value)
Add a name/value pair into this object.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - A long with the value.

add

public void add(java.lang.String name,
                java.lang.String[] value)
Add an array of Strings for a key. This is simply adding all the elements in the array one by one.

Specified by:
add in interface ValueParser
Parameters:
name - A String with the name.
value - A String Array.

append

public void append(java.lang.String name,
                   java.lang.String value)
Deprecated. Use add(name, value) instead.

Add a String parameters. If there are any Strings already associated with the name, append to the array. This is used for handling parameters from multipart POST requests.

Specified by:
append in interface ValueParser
Parameters:
name - A String with the name.
value - A String with the value.

remove

public java.lang.Object remove(java.lang.String name)
Removes the named parameter from the contained hashtable. Wraps to the contained Map.remove().

Specified by:
remove in interface ValueParser
Returns:
The value that was mapped to the key (a String[]) or null if the key was not mapped.

convert

public java.lang.String convert(java.lang.String value)
Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING. It returns a new string so that it does not destroy the value data.

Specified by:
convert in interface ValueParser
Parameters:
value - A String to be processed.
Returns:
A new String converted to lowercase and trimmed.

containsKey

public boolean containsKey(java.lang.Object key)
Determine whether a given key has been inserted. All keys are stored in lowercase strings, so override method to account for this.

Specified by:
containsKey in interface ValueParser
Parameters:
key - An Object with the key to search for.
Returns:
True if the object is found.

containsDateSelectorKeys

public boolean containsDateSelectorKeys(java.lang.String key)
Check for existence of key_day, key_month and key_year parameters (as returned by DateSelector generated HTML).

Specified by:
containsDateSelectorKeys in interface ValueParser
Parameters:
key - A String with the selector name.
Returns:
True if keys are found.

containsTimeSelectorKeys

public boolean containsTimeSelectorKeys(java.lang.String key)
Check for existence of key_hour, key_minute and key_second parameters (as returned by TimeSelector generated HTML).

Parameters:
key - A String with the selector name.
Returns:
True if keys are found.

keys

public java.util.Enumeration keys()
Deprecated. use keySet() instead.

Get an enumerator for the parameter keys.

Specified by:
keys in interface ValueParser
Returns:
An enumerator of the keys.

keySet

public java.util.Set keySet()
Gets the set of keys

Specified by:
keySet in interface ValueParser
Returns:
A Set of the keys.

getKeys

public java.lang.Object[] getKeys()
Returns all the available parameter names.

Specified by:
getKeys in interface ValueParser
Returns:
A object array with the keys.

getBoolean

public boolean getBoolean(java.lang.String name,
                          boolean defaultValue)
Return a boolean for the given name. If the name does not exist, return defaultValue.

Specified by:
getBoolean in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A boolean.

getBoolean

public boolean getBoolean(java.lang.String name)
Return a boolean for the given name. If the name does not exist, return false.

Specified by:
getBoolean in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A boolean.

getBooleans

public boolean[] getBooleans(java.lang.String name)
Return an array of booleans for the given name. If the name does not exist, return null.

Specified by:
getBooleans in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A boolean[].

getBooleanObject

public java.lang.Boolean getBooleanObject(java.lang.String name)
Returns a Boolean object for the given name. If the parameter does not exist or can not be parsed as a boolean, null is returned.

Valid values for true: true, on, 1, yes
Valid values for false: false, off, 0, no

The string is compared without reguard to case.

Specified by:
getBooleanObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Boolean.

getBooleanObject

public java.lang.Boolean getBooleanObject(java.lang.String name,
                                          java.lang.Boolean defaultValue)
Returns a Boolean object for the given name. If the parameter does not exist or can not be parsed as a boolean, null is returned.

Valid values for true: true, on, 1, yes
Valid values for false: false, off, 0, no

The string is compared without reguard to case.

Specified by:
getBooleanObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A Boolean.

getBool

public java.lang.Boolean getBool(java.lang.String name,
                                 boolean defaultValue)
Deprecated. use getBooleanObject(java.lang.String) instead

Return a Boolean for the given name. If the name does not exist, return defaultValue.

Specified by:
getBool in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A Boolean.

getBool

public java.lang.Boolean getBool(java.lang.String name)
Deprecated. use getBooleanObject(String) instead

Return a Boolean for the given name. If the name does not exist, return false.

Specified by:
getBool in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Boolean.

getBooleanObjects

public java.lang.Boolean[] getBooleanObjects(java.lang.String name)
Return an array of Booleans for the given name. If the name does not exist, return null.

Specified by:
getBooleanObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Boolean[].

getDouble

public double getDouble(java.lang.String name,
                        double defaultValue)
Return a double for the given name. If the name does not exist, return defaultValue.

Specified by:
getDouble in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A double.

getDouble

public double getDouble(java.lang.String name)
Return a double for the given name. If the name does not exist, return 0.0.

Specified by:
getDouble in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A double.

getDoubles

public double[] getDoubles(java.lang.String name)
Return an array of doubles for the given name. If the name does not exist, return null.

Specified by:
getDoubles in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A double[].

getDoubleObject

public java.lang.Double getDoubleObject(java.lang.String name,
                                        java.lang.Double defaultValue)
Return a Double for the given name. If the name does not exist, return defaultValue.

Specified by:
getDoubleObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A double.

getDoubleObject

public java.lang.Double getDoubleObject(java.lang.String name)
Return a Double for the given name. If the name does not exist, return null.

Specified by:
getDoubleObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A double.

getDoubleObjects

public java.lang.Double[] getDoubleObjects(java.lang.String name)
Return an array of doubles for the given name. If the name does not exist, return null.

Specified by:
getDoubleObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A double[].

getFloat

public float getFloat(java.lang.String name,
                      float defaultValue)
Return a float for the given name. If the name does not exist, return defaultValue.

Specified by:
getFloat in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A float.

getFloat

public float getFloat(java.lang.String name)
Return a float for the given name. If the name does not exist, return 0.0.

Specified by:
getFloat in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A float.

getFloats

public float[] getFloats(java.lang.String name)
Return an array of floats for the given name. If the name does not exist, return null.

Specified by:
getFloats in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A float[].

getFloatObject

public java.lang.Float getFloatObject(java.lang.String name,
                                      java.lang.Float defaultValue)
Return a Float for the given name. If the name does not exist, return defaultValue.

Specified by:
getFloatObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A Float.

getFloatObject

public java.lang.Float getFloatObject(java.lang.String name)
Return a float for the given name. If the name does not exist, return null.

Specified by:
getFloatObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Float.

getFloatObjects

public java.lang.Float[] getFloatObjects(java.lang.String name)
Return an array of floats for the given name. If the name does not exist, return null.

Specified by:
getFloatObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A float[].

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String name,
                                          java.math.BigDecimal defaultValue)
Return a BigDecimal for the given name. If the name does not exist, return defaultValue.

Specified by:
getBigDecimal in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A BigDecimal.

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String name)
Return a BigDecimal for the given name. If the name does not exist, return null.

Specified by:
getBigDecimal in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A BigDecimal.

getBigDecimals

public java.math.BigDecimal[] getBigDecimals(java.lang.String name)
Return an array of BigDecimals for the given name. If the name does not exist, return null.

Specified by:
getBigDecimals in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A BigDecimal[].

getInt

public int getInt(java.lang.String name,
                  int defaultValue)
Return an int for the given name. If the name does not exist, return defaultValue.

Specified by:
getInt in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
An int.

getInt

public int getInt(java.lang.String name)
Return an int for the given name. If the name does not exist, return 0.

Specified by:
getInt in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An int.

getInteger

public java.lang.Integer getInteger(java.lang.String name,
                                    int defaultValue)
Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead

Return an Integer for the given name. If the name does not exist, return defaultValue.

Specified by:
getInteger in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
An Integer.

getInteger

public java.lang.Integer getInteger(java.lang.String name,
                                    java.lang.Integer def)
Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead

Return an Integer for the given name. If the name does not exist, return defaultValue. You cannot pass in a null here for the default value.

Specified by:
getInteger in interface ValueParser
Parameters:
name - A String with the name.
def - The default value.
Returns:
An Integer.

getInteger

public java.lang.Integer getInteger(java.lang.String name)
Deprecated. use getIntObject(java.lang.String, java.lang.Integer) instead

Return an Integer for the given name. If the name does not exist, return 0.

Specified by:
getInteger in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Integer.

getInts

public int[] getInts(java.lang.String name)
Return an array of ints for the given name. If the name does not exist, return null.

Specified by:
getInts in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An int[].

getIntObject

public java.lang.Integer getIntObject(java.lang.String name,
                                      java.lang.Integer defaultValue)
Return an Integer for the given name. If the name does not exist, return defaultValue.

Specified by:
getIntObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
An Integer.

getIntObject

public java.lang.Integer getIntObject(java.lang.String name)
Return an Integer for the given name. If the name does not exist, return null.

Specified by:
getIntObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Integer.

getIntObjects

public java.lang.Integer[] getIntObjects(java.lang.String name)
Return an array of Integers for the given name. If the name does not exist, return null.

Specified by:
getIntObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Integer[].

getIntegers

public java.lang.Integer[] getIntegers(java.lang.String name)
Deprecated. use getIntObjects(java.lang.String) instead

Return an array of Integers for the given name. If the name does not exist, return null.

Specified by:
getIntegers in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Integer[].

getLong

public long getLong(java.lang.String name,
                    long defaultValue)
Return a long for the given name. If the name does not exist, return defaultValue.

Specified by:
getLong in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A long.

getLong

public long getLong(java.lang.String name)
Return a long for the given name. If the name does not exist, return 0.

Specified by:
getLong in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A long.

getLongs

public long[] getLongs(java.lang.String name)
Return an array of longs for the given name. If the name does not exist, return null.

Specified by:
getLongs in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A long[].

getLongObjects

public java.lang.Long[] getLongObjects(java.lang.String name)
Return an array of Longs for the given name. If the name does not exist, return null.

Specified by:
getLongObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Long[].

getLongObject

public java.lang.Long getLongObject(java.lang.String name)
Return a Long for the given name. If the name does not exist, return null.

Specified by:
getLongObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Long.

getLongObject

public java.lang.Long getLongObject(java.lang.String name,
                                    java.lang.Long defaultValue)
Return a Long for the given name. If the name does not exist, return the default value.

Specified by:
getLongObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A Long.

getByte

public byte getByte(java.lang.String name,
                    byte defaultValue)
Return a byte for the given name. If the name does not exist, return defaultValue.

Specified by:
getByte in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A byte.

getByte

public byte getByte(java.lang.String name)
Return a byte for the given name. If the name does not exist, return 0.

Specified by:
getByte in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A byte.

getBytes

public byte[] getBytes(java.lang.String name)
                throws java.io.UnsupportedEncodingException
Return an array of bytes for the given name. If the name does not exist, return null. The array is returned according to the HttpRequest's character encoding.

Specified by:
getBytes in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A byte[].
Throws:
java.io.UnsupportedEncodingException

getByteObject

public java.lang.Byte getByteObject(java.lang.String name,
                                    java.lang.Byte defaultValue)
Return a byte for the given name. If the name does not exist, return defaultValue.

Specified by:
getByteObject in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A byte.

getByteObject

public java.lang.Byte getByteObject(java.lang.String name)
Return a byte for the given name. If the name does not exist, return 0.

Specified by:
getByteObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A byte.

getString

public java.lang.String getString(java.lang.String name)
Return a String for the given name. If the name does not exist, return null.

Specified by:
getString in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A String or null if the key is unknown.

get

public java.lang.String get(java.lang.String name)
Return a String for the given name. If the name does not exist, return null. It is the same as the getString() method however has been added for simplicity when working with template tools such as Velocity which allow you to do something like this: $data.Parameters.form_variable_name

Specified by:
get in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A String.

getString

public java.lang.String getString(java.lang.String name,
                                  java.lang.String defaultValue)
Return a String for the given name. If the name does not exist, return the defaultValue.

Specified by:
getString in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A String.

setString

public void setString(java.lang.String name,
                      java.lang.String value)
Set a parameter to a specific value. This is useful if you want your action to override the values of the parameters for the screen to use.

Specified by:
setString in interface ValueParser
Parameters:
name - The name of the parameter.
value - The value to set.

getStrings

public java.lang.String[] getStrings(java.lang.String name)
Return an array of Strings for the given name. If the name does not exist, return null.

Specified by:
getStrings in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A String[].

getStrings

public java.lang.String[] getStrings(java.lang.String name,
                                     java.lang.String[] defaultValue)
Return an array of Strings for the given name. If the name does not exist, return the defaultValue.

Specified by:
getStrings in interface ValueParser
Parameters:
name - A String with the name.
defaultValue - The default value.
Returns:
A String[].

setStrings

public void setStrings(java.lang.String name,
                       java.lang.String[] values)
Set a parameter to a specific value. This is useful if you want your action to override the values of the parameters for the screen to use.

Specified by:
setStrings in interface ValueParser
Parameters:
name - The name of the parameter.
values - The value to set.

getObject

public java.lang.Object getObject(java.lang.String name)
Return an Object for the given name. If the name does not exist, return null.

Specified by:
getObject in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Object.

getObjects

public java.lang.Object[] getObjects(java.lang.String name)
Return an array of Objects for the given name. If the name does not exist, return null.

Specified by:
getObjects in interface ValueParser
Parameters:
name - A String with the name.
Returns:
An Object[].

getDate

public java.util.Date getDate(java.lang.String name,
                              java.text.DateFormat df,
                              java.util.Date defaultValue)
Returns a Date object. String is parsed by supplied DateFormat. If the name does not exist or the value could not be parsed into a date return the defaultValue.

Specified by:
getDate in interface ValueParser
Parameters:
name - A String with the name.
df - A DateFormat.
defaultValue - The default value.
Returns:
A Date.

getDate

public java.util.Date getDate(java.lang.String name)
Returns a Date object. If there are DateSelector or TimeSelector style parameters then these are used. If not and there is a parameter 'name' then this is parsed by DateFormat. If the name does not exist, return null.

Specified by:
getDate in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A Date.

getDate

public java.util.Date getDate(java.lang.String name,
                              java.text.DateFormat df)
Returns a Date object. String is parsed by supplied DateFormat. If the name does not exist, return null.

Specified by:
getDate in interface ValueParser
Parameters:
name - A String with the name.
df - A DateFormat.
Returns:
A Date.

getNumberKey

public org.apache.torque.om.NumberKey getNumberKey(java.lang.String name)
Deprecated. no replacement

Return an NumberKey for the given name. If the name does not exist, return null.

Specified by:
getNumberKey in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A NumberKey, or null if unparsable.

getStringKey

public org.apache.torque.om.StringKey getStringKey(java.lang.String name)
Deprecated. no replacement

Return an StringKey for the given name. If the name does not exist, return null.

Specified by:
getStringKey in interface ValueParser
Parameters:
name - A String with the name.
Returns:
A StringKey, or null if unparsable.

setProperties

public void setProperties(java.lang.Object bean)
                   throws java.lang.Exception
Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for.

Specified by:
setProperties in interface ValueParser
Parameters:
bean - An Object.
Throws:
java.lang.Exception - a generic exception.

toString

public java.lang.String toString()
Simple method that attempts to get a textual representation of this object's name/value pairs. String[] handling is currently a bit rough.

Specified by:
toString in interface ValueParser
Returns:
A textual representation of the parsed name/value pairs.

getToStringParam

protected java.lang.Object[] getToStringParam(java.lang.String name)
This method is only used in toString() and can be used by derived classes to add their local parameters to the toString()

Parameters:
name - A string with the name
Returns:
the value object array or null if not set

setProperty

protected void setProperty(java.lang.Object bean,
                           java.beans.PropertyDescriptor prop)
                    throws java.lang.Exception
Set the property 'prop' in the bean to the value of the corresponding parameters. Supports all types supported by getXXX methods plus a few more that come for free because primitives have to be wrapped before being passed to invoke anyway.

Parameters:
bean - An Object.
prop - A PropertyDescriptor.
Throws:
java.lang.Exception - a generic exception.

putParam

protected void putParam(java.lang.String name,
                        java.lang.String[] value)
Puts a key into the parameters map. Makes sure that the name is always mapped correctly. This method also enforces the usage of arrays for the parameters.

Parameters:
name - A String with the name.
value - An array of Objects with the values.

getParam

protected java.lang.String[] getParam(java.lang.String name)
fetches a key from the parameters map. Makes sure that the name is always mapped correctly.

Parameters:
name - A string with the name
Returns:
the value object array or null if not set


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.