|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> misc >> [ upload overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jcorporate.expresso.core.misc.upload
Class BaseValueParser

java.lang.Objectcom.jcorporate.expresso.core.misc.upload.BaseValueParser
- All Implemented Interfaces:
- ValueParser
- Direct Known Subclasses:
- DefaultParameterParser
- public class BaseValueParser
- extends java.lang.Object
- implements ValueParser
- extends java.lang.Object
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,v 1.7 2004/11/18 02:03:27 lhamel Exp $
| Field Summary | |
private java.lang.String |
characterEncoding
The character encoding to use when converting to byte arrays |
protected java.util.Hashtable |
parameters
Random access storage for parameter data. |
| Fields inherited from interface com.jcorporate.expresso.core.misc.upload.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 newEncoding)
Constructor that takes a character encoding |
|
| 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 |
append(java.lang.String name,
java.lang.String value)
Add a String parameters. |
void |
clear()
Clear all name/value pairs out of this object. |
boolean |
containsKey(java.lang.Object key)
Determine whether a given key has been inserted. |
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)
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. |
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)
Return a Boolean for the given name. |
java.lang.Boolean |
getBool(java.lang.String name,
boolean defaultValue)
Return a Boolean for the given name. |
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. |
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. |
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. |
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. |
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. |
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)
Return an Integer for the given name. |
java.lang.Integer |
getInteger(java.lang.String name,
int defaultValue)
Return an Integer for the given name. |
java.lang.Integer |
getInteger(java.lang.String name,
java.lang.Integer def)
Return an Integer for the given name. |
java.lang.Integer[] |
getIntegers(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()
|
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[] |
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.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. |
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. |
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. |
java.util.Enumeration |
keys()
|
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 |
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. |
private 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 toString() representation of this object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
parameters
protected java.util.Hashtable parameters
- Random access storage for parameter data.
characterEncoding
private java.lang.String characterEncoding
- The character encoding to use when converting to byte arrays
| Constructor Detail |
BaseValueParser
public BaseValueParser()
- Default constructor
BaseValueParser
public BaseValueParser(java.lang.String newEncoding)
- Constructor that takes a character encoding
| Method Detail |
convertAndTrim
public static java.lang.String convertAndTrim(java.lang.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. It returns a new
string so that it does not destroy the value data.
dispose
public void dispose()
- Disposes the parser.
clear
public void clear()
- Clear all name/value pairs out of this object.
- Specified by:
clearin interfaceValueParser
setCharacterEncoding
public void setCharacterEncoding(java.lang.String s)
- Set the character encoding that will be used by this ValueParser.
- Specified by:
setCharacterEncodingin interfaceValueParser
getCharacterEncoding
public java.lang.String getCharacterEncoding()
- Get the character encoding that will be used by this ValueParser.
- Specified by:
getCharacterEncodingin interfaceValueParser
add
public void add(java.lang.String name, double value)
- Add a name/value pair into this object.
- Specified by:
addin interfaceValueParser
add
public void add(java.lang.String name, int value)
- Add a name/value pair into this object.
- Specified by:
addin interfaceValueParser
add
public void add(java.lang.String name, java.lang.Integer value)
- Add a name/value pair into this object.
- Specified by:
addin interfaceValueParser
add
public void add(java.lang.String name, long value)
- Add a name/value pair into this object.
- Specified by:
addin interfaceValueParser
add
public void add(java.lang.String name, java.lang.String value)
- Add a name/value pair into this object.
- Specified by:
addin interfaceValueParser
append
public void append(java.lang.String name, java.lang.String value)
- 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.
- Specified by:
appendin interfaceValueParser
remove
public java.lang.Object remove(java.lang.String name)
- Removes the named parameter from the contained hashtable. Wraps to the
contained
Hashtable.remove().- Specified by:
removein interfaceValueParser
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:
convertin interfaceValueParser
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:
containsKeyin interfaceValueParser
keys
public java.util.Enumeration keys()
- Specified by:
keysin interfaceValueParser
getKeys
public java.lang.Object[] getKeys()
- Specified by:
getKeysin interfaceValueParser
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:
getBooleanin interfaceValueParser
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:
getBooleanin interfaceValueParser
getBool
public java.lang.Boolean getBool(java.lang.String name, boolean defaultValue)
- Return a Boolean for the given name. If the name does not
exist, return defaultValue.
- Specified by:
getBoolin interfaceValueParser
getBool
public java.lang.Boolean getBool(java.lang.String name)
- Return a Boolean for the given name. If the name does not
exist, return false.
- Specified by:
getBoolin interfaceValueParser
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:
getDoublein interfaceValueParser
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:
getDoublein interfaceValueParser
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:
getFloatin interfaceValueParser
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:
getFloatin interfaceValueParser
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 0.0.
- Specified by:
getBigDecimalin interfaceValueParser
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.String name)
- Return a BigDecimal for the given name. If the name does not
exist, return 0.0.
- Specified by:
getBigDecimalin interfaceValueParser
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:
getBigDecimalsin interfaceValueParser
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:
getIntin interfaceValueParser
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:
getIntin interfaceValueParser
getInteger
public java.lang.Integer getInteger(java.lang.String name, int defaultValue)
- Return an Integer for the given name. If the name does not
exist, return defaultValue.
- Specified by:
getIntegerin interfaceValueParser
getInteger
public java.lang.Integer getInteger(java.lang.String name, java.lang.Integer def)
- 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:
getIntegerin interfaceValueParser
getInteger
public java.lang.Integer getInteger(java.lang.String name)
- Return an Integer for the given name. If the name does not
exist, return 0.
- Specified by:
getIntegerin interfaceValueParser
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:
getIntsin interfaceValueParser
getIntegers
public java.lang.Integer[] getIntegers(java.lang.String name)
- Return an array of Integers for the given name. If the name
does not exist, return null.
- Specified by:
getIntegersin interfaceValueParser
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:
getLongin interfaceValueParser
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:
getLongin interfaceValueParser
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:
getLongsin interfaceValueParser
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:
getLongObjectsin interfaceValueParser
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:
getBytein interfaceValueParser
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:
getBytein interfaceValueParser
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:
getBytesin interfaceValueParser
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:
getStringin interfaceValueParser
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:
getin interfaceValueParser
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:
getStringin interfaceValueParser
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:
setStringin interfaceValueParser
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:
getStringsin interfaceValueParser
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:
getStringsin interfaceValueParser
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:
setStringsin interfaceValueParser
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:
getObjectin interfaceValueParser
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:
getObjectsin interfaceValueParser
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:
setPropertiesin interfaceValueParser
toString
public java.lang.String toString()
- Simple method that attempts to get a toString() representation
of this object. It doesn't do well with String[]'s though.
- Specified by:
toStringin interfaceValueParser
setProperty
private 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.
|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> misc >> [ upload overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.jcorporate.expresso.core.misc.upload.BaseValueParser