| java.lang.Object com.jcorporate.expresso.core.misc.upload.BaseValueParser
All known Subclasses: com.jcorporate.expresso.core.misc.upload.DefaultParameterParser,
BaseValueParser | public class BaseValueParser implements ValueParser(Code) | | 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.
author: Ilkka Priha author: Jon S. Stevens author: Sean Legassick author: Jason van Zyl version: $Id: BaseValueParser.java,v 1.7 2004/11/18 02:03:27 lhamel Exp $ |
Method Summary | |
public void | add(String name, double value) Add a name/value pair into this object. | public void | add(String name, int value) Add a name/value pair into this object. | public void | add(String name, Integer value) Add a name/value pair into this object. | public void | add(String name, long value) Add a name/value pair into this object. | public void | add(String name, String value) Add a name/value pair into this object. | public void | append(String name, String value) Add a String parameters. | public void | clear() Clear all name/value pairs out of this object. | public boolean | containsKey(Object key) Determine whether a given key has been inserted. | public String | convert(String value) Trims the string data and applies the conversion specified in
the property given by URL_CASE_FOLDING. | public static String | convertAndTrim(String 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. | public void | dispose() Disposes the parser. | public String | get(String name) Return a String for the given name. | public BigDecimal | getBigDecimal(String name, BigDecimal defaultValue) Return a BigDecimal for the given name. | public BigDecimal | getBigDecimal(String name) Return a BigDecimal for the given name. | public BigDecimal[] | getBigDecimals(String name) Return an array of BigDecimals for the given name. | public Boolean | getBool(String name, boolean defaultValue) Return a Boolean for the given name. | public Boolean | getBool(String name) Return a Boolean for the given name. | public boolean | getBoolean(String name, boolean defaultValue) Return a boolean for the given name. | public boolean | getBoolean(String name) Return a boolean for the given name. | public byte | getByte(String name, byte defaultValue) Return a byte for the given name. | public byte | getByte(String name) Return a byte for the given name. | public byte[] | getBytes(String name) Return an array of bytes for the given name. | public String | getCharacterEncoding() Get the character encoding that will be used by this ValueParser. | public double | getDouble(String name, double defaultValue) Return a double for the given name. | public double | getDouble(String name) Return a double for the given name. | public float | getFloat(String name, float defaultValue) Return a float for the given name. | public float | getFloat(String name) Return a float for the given name. | public int | getInt(String name, int defaultValue) Return an int for the given name. | public int | getInt(String name) Return an int for the given name. | public Integer | getInteger(String name, int defaultValue) Return an Integer for the given name. | public Integer | getInteger(String name, Integer def) Return an Integer for the given name. | public Integer | getInteger(String name) Return an Integer for the given name. | public Integer[] | getIntegers(String name) Return an array of Integers for the given name. | public int[] | getInts(String name) Return an array of ints for the given name. | public Object[] | getKeys() | public long | getLong(String name, long defaultValue) Return a long for the given name. | public long | getLong(String name) Return a long for the given name. | public Long[] | getLongObjects(String name) Return an array of Longs for the given name. | public long[] | getLongs(String name) Return an array of longs for the given name. | public Object | getObject(String name) Return an Object for the given name. | public Object[] | getObjects(String name) Return an array of Objects for the given name. | public String | getString(String name) Return a String for the given name. | public String | getString(String name, String defaultValue) Return a String for the given name. | public String[] | getStrings(String name) Return an array of Strings for the given name. | public String[] | getStrings(String name, String[] defaultValue) Return an array of Strings for the given name. | public Enumeration | keys() | public Object | remove(String name) Removes the named parameter from the contained hashtable. | public void | setCharacterEncoding(String s) Set the character encoding that will be used by this ValueParser. | public void | setProperties(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. | public void | setString(String name, String value) Set a parameter to a specific value. | public void | setStrings(String name, String[] values) Set a parameter to a specific value. | public String | toString() Simple method that attempts to get a toString() representation
of this object. |
parameters | protected Hashtable parameters(Code) | | Random access storage for parameter data.
|
BaseValueParser | public BaseValueParser()(Code) | | Default constructor
|
BaseValueParser | public BaseValueParser(String newEncoding)(Code) | | Constructor that takes a character encoding
|
add | public void add(String name, double value)(Code) | | Add a name/value pair into this object.
Parameters: name - A String with the name. Parameters: value - A double with the value. |
add | public void add(String name, int value)(Code) | | Add a name/value pair into this object.
Parameters: name - A String with the name. Parameters: value - An int with the value. |
add | public void add(String name, Integer value)(Code) | | Add a name/value pair into this object.
Parameters: name - A String with the name. Parameters: value - An Integer with the value. |
add | public void add(String name, long value)(Code) | | Add a name/value pair into this object.
Parameters: name - A String with the name. Parameters: value - A long with the value. |
add | public void add(String name, String value)(Code) | | Add a name/value pair into this object.
Parameters: name - A String with the name. Parameters: value - A long with the value. |
append | public void append(String name, String value)(Code) | | 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 mulitipart POST requests.
Parameters: name - A String with the name. Parameters: value - A String with the value. |
clear | public void clear()(Code) | | Clear all name/value pairs out of this object.
|
containsKey | public boolean containsKey(Object key)(Code) | | Determine whether a given key has been inserted. All keys are
stored in lowercase strings, so override method to account for
this.
Parameters: key - An Object with the key to search for. True if the object is found. |
convert | public String convert(String value)(Code) | | 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. A new String converted to lowercase and trimmed. |
convertAndTrim | public static String convertAndTrim(String value)(Code) | | 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. A new String converted to lowercase and trimmed. |
dispose | public void dispose()(Code) | | Disposes the parser.
|
get | public String get(String name)(Code) | | 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
Parameters: name - A String with the name. A String. |
getBigDecimal | public BigDecimal getBigDecimal(String name, BigDecimal defaultValue)(Code) | | Return a BigDecimal for the given name. If the name does not
exist, return 0.0.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A BigDecimal. |
getBigDecimal | public BigDecimal getBigDecimal(String name)(Code) | | Return a BigDecimal for the given name. If the name does not
exist, return 0.0.
Parameters: name - A String with the name. A BigDecimal. |
getBigDecimals | public BigDecimal[] getBigDecimals(String name)(Code) | | Return an array of BigDecimals for the given name. If the name
does not exist, return null.
Parameters: name - A String with the name. A BigDecimal[]. |
getBool | public Boolean getBool(String name, boolean defaultValue)(Code) | | Return a Boolean for the given name. If the name does not
exist, return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A Boolean. |
getBool | public Boolean getBool(String name)(Code) | | Return a Boolean for the given name. If the name does not
exist, return false.
Parameters: name - A String with the name. A Boolean. |
getBoolean | public boolean getBoolean(String name, boolean defaultValue)(Code) | | Return a boolean for the given name. If the name does not
exist, return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A boolean. |
getBoolean | public boolean getBoolean(String name)(Code) | | Return a boolean for the given name. If the name does not
exist, return false.
Parameters: name - A String with the name. A boolean. |
getByte | public byte getByte(String name, byte defaultValue)(Code) | | Return a byte for the given name. If the name does not exist,
return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A byte. |
getByte | public byte getByte(String name)(Code) | | Return a byte for the given name. If the name does not exist,
return 0.
Parameters: name - A String with the name. A byte. |
getBytes | public byte[] getBytes(String name) throws UnsupportedEncodingException(Code) | | 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.
Parameters: name - A String with the name. A byte[]. |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Get the character encoding that will be used by this ValueParser.
|
getDouble | public double getDouble(String name, double defaultValue)(Code) | | Return a double for the given name. If the name does not
exist, return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A double. |
getDouble | public double getDouble(String name)(Code) | | Return a double for the given name. If the name does not
exist, return 0.0.
Parameters: name - A String with the name. A double. |
getFloat | public float getFloat(String name, float defaultValue)(Code) | | Return a float for the given name. If the name does not
exist, return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A float. |
getFloat | public float getFloat(String name)(Code) | | Return a float for the given name. If the name does not
exist, return 0.0.
Parameters: name - A String with the name. A float. |
getInt | public int getInt(String name, int defaultValue)(Code) | | Return an int for the given name. If the name does not exist,
return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. An int. |
getInt | public int getInt(String name)(Code) | | Return an int for the given name. If the name does not exist,
return 0.
Parameters: name - A String with the name. An int. |
getInteger | public Integer getInteger(String name, int defaultValue)(Code) | | Return an Integer for the given name. If the name does not
exist, return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. An Integer. |
getInteger | public Integer getInteger(String name, Integer def)(Code) | | 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.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. An Integer. |
getInteger | public Integer getInteger(String name)(Code) | | Return an Integer for the given name. If the name does not
exist, return 0.
Parameters: name - A String with the name. An Integer. |
getIntegers | public Integer[] getIntegers(String name)(Code) | | Return an array of Integers for the given name. If the name
does not exist, return null.
Parameters: name - A String with the name. An Integer[]. |
getInts | public int[] getInts(String name)(Code) | | Return an array of ints for the given name. If the name does
not exist, return null.
Parameters: name - A String with the name. An int[]. |
getLong | public long getLong(String name, long defaultValue)(Code) | | Return a long for the given name. If the name does not exist,
return defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A long. |
getLong | public long getLong(String name)(Code) | | Return a long for the given name. If the name does not exist,
return 0.
Parameters: name - A String with the name. A long. |
getLongObjects | public Long[] getLongObjects(String name)(Code) | | Return an array of Longs for the given name. If the name does
not exist, return null.
Parameters: name - A String with the name. A Long[]. |
getLongs | public long[] getLongs(String name)(Code) | | Return an array of longs for the given name. If the name does
not exist, return null.
Parameters: name - A String with the name. A long[]. |
getObject | public Object getObject(String name)(Code) | | Return an Object for the given name. If the name does not
exist, return null.
Parameters: name - A String with the name. An Object. |
getObjects | public Object[] getObjects(String name)(Code) | | Return an array of Objects for the given name. If the name
does not exist, return null.
Parameters: name - A String with the name. An Object[]. |
getString | public String getString(String name)(Code) | | Return a String for the given name. If the name does not
exist, return null.
Parameters: name - A String with the name. A String. |
getString | public String getString(String name, String defaultValue)(Code) | | Return a String for the given name. If the name does not
exist, return the defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A String. |
getStrings | public String[] getStrings(String name)(Code) | | Return an array of Strings for the given name. If the name
does not exist, return null.
Parameters: name - A String with the name. A String[]. |
getStrings | public String[] getStrings(String name, String[] defaultValue)(Code) | | Return an array of Strings for the given name. If the name
does not exist, return the defaultValue.
Parameters: name - A String with the name. Parameters: defaultValue - The default value. A String[]. |
remove | public Object remove(String name)(Code) | | Removes the named parameter from the contained hashtable. Wraps to the
contained Hashtable.remove() .
The value that was mapped to the key (a String[] )or null if the key was not mapped. |
setCharacterEncoding | public void setCharacterEncoding(String s)(Code) | | Set the character encoding that will be used by this ValueParser.
|
setProperties | public void setProperties(Object bean) throws Exception(Code) | | 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.
Parameters: bean - An Object. throws: Exception - , a generic exception. |
setString | public void setString(String name, String value)(Code) | | 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.
Parameters: name - The name of the parameter. Parameters: value - The value to set. |
setStrings | public void setStrings(String name, String[] values)(Code) | | 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.
Parameters: name - The name of the parameter. Parameters: values - The value to set. |
toString | public String toString()(Code) | | Simple method that attempts to get a toString() representation
of this object. It doesn't do well with String[]'s though.
A String. |
|
|