|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.util.pool.RecyclableSupport
org.apache.turbine.util.parser.BaseValueParser
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.
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 |
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. |
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. |
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. |
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. |
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 |
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 |
public BaseValueParser()
public BaseValueParser(java.lang.String characterEncoding)
Method Detail |
public static java.lang.String convertAndTrim(java.lang.String value)
value
- A String to be processed.
public void recycle(java.lang.String characterEncoding)
characterEncoding
- the character encoding.public void dispose()
dispose
in interface Recyclable
dispose
in class RecyclableSupport
public void clear()
clear
in interface ValueParser
public void setCharacterEncoding(java.lang.String s)
setCharacterEncoding
in interface ValueParser
public java.lang.String getCharacterEncoding()
getCharacterEncoding
in interface ValueParser
public void add(java.lang.String name, double value)
add
in interface ValueParser
name
- A String with the name.value
- A double with the value.public void add(java.lang.String name, int value)
add
in interface ValueParser
name
- A String with the name.value
- An int with the value.public void add(java.lang.String name, java.lang.Integer value)
add
in interface ValueParser
name
- A String with the name.value
- An Integer with the value.public void add(java.lang.String name, long value)
add
in interface ValueParser
name
- A String with the name.value
- A long with the value.public void add(java.lang.String name, java.lang.String value)
add
in interface ValueParser
name
- A String with the name.value
- A long with the value.public void add(java.lang.String name, java.lang.String[] value)
add
in interface ValueParser
name
- A String with the name.value
- A String Array.public void append(java.lang.String name, java.lang.String value)
append
in interface ValueParser
name
- A String with the name.value
- A String with the value.public java.lang.Object remove(java.lang.String name)
Map.remove()
.
remove
in interface ValueParser
String[]
)
or null
if the key was not mapped.public java.lang.String convert(java.lang.String value)
convert
in interface ValueParser
value
- A String to be processed.
public boolean containsKey(java.lang.Object key)
containsKey
in interface ValueParser
key
- An Object with the key to search for.
public boolean containsDateSelectorKeys(java.lang.String key)
containsDateSelectorKeys
in interface ValueParser
key
- A String with the selector name.
public boolean containsTimeSelectorKeys(java.lang.String key)
key
- A String with the selector name.
public java.util.Enumeration keys()
keySet()
instead.
keys
in interface ValueParser
enumerator
of the keys.public java.util.Set keySet()
keySet
in interface ValueParser
Set
of the keys.public java.lang.Object[] getKeys()
getKeys
in interface ValueParser
public boolean getBoolean(java.lang.String name, boolean defaultValue)
getBoolean
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public boolean getBoolean(java.lang.String name)
getBoolean
in interface ValueParser
name
- A String with the name.
public java.lang.Boolean getBooleanObject(java.lang.String name)
Valid values for true: true, on, 1, yes
Valid values for false: false, off, 0, no
The string is compared without reguard to case.
getBooleanObject
in interface ValueParser
name
- A String with the name.
public java.lang.Boolean getBooleanObject(java.lang.String name, java.lang.Boolean defaultValue)
Valid values for true: true, on, 1, yes
Valid values for false: false, off, 0, no
The string is compared without reguard to case.
getBooleanObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Boolean getBool(java.lang.String name, boolean defaultValue)
getBooleanObject(java.lang.String)
instead
getBool
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Boolean getBool(java.lang.String name)
getBooleanObject(String)
instead
getBool
in interface ValueParser
name
- A String with the name.
public double getDouble(java.lang.String name, double defaultValue)
getDouble
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public double getDouble(java.lang.String name)
getDouble
in interface ValueParser
name
- A String with the name.
public double[] getDoubles(java.lang.String name)
getDoubles
in interface ValueParser
name
- A String with the name.
public java.lang.Double getDoubleObject(java.lang.String name, java.lang.Double defaultValue)
getDoubleObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Double getDoubleObject(java.lang.String name)
getDoubleObject
in interface ValueParser
name
- A String with the name.
public java.lang.Double[] getDoubleObjects(java.lang.String name)
getDoubleObjects
in interface ValueParser
name
- A String with the name.
public float getFloat(java.lang.String name, float defaultValue)
getFloat
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public float getFloat(java.lang.String name)
getFloat
in interface ValueParser
name
- A String with the name.
public float[] getFloats(java.lang.String name)
getFloats
in interface ValueParser
name
- A String with the name.
public java.lang.Float getFloatObject(java.lang.String name, java.lang.Float defaultValue)
getFloatObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Float getFloatObject(java.lang.String name)
getFloatObject
in interface ValueParser
name
- A String with the name.
public java.lang.Float[] getFloatObjects(java.lang.String name)
getFloatObjects
in interface ValueParser
name
- A String with the name.
public java.math.BigDecimal getBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
getBigDecimal
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.math.BigDecimal getBigDecimal(java.lang.String name)
getBigDecimal
in interface ValueParser
name
- A String with the name.
public java.math.BigDecimal[] getBigDecimals(java.lang.String name)
getBigDecimals
in interface ValueParser
name
- A String with the name.
public int getInt(java.lang.String name, int defaultValue)
getInt
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public int getInt(java.lang.String name)
getInt
in interface ValueParser
name
- A String with the name.
public java.lang.Integer getInteger(java.lang.String name, int defaultValue)
getIntObject(java.lang.String, java.lang.Integer)
instead
getInteger
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Integer getInteger(java.lang.String name, java.lang.Integer def)
getIntObject(java.lang.String, java.lang.Integer)
instead
getInteger
in interface ValueParser
name
- A String with the name.def
- The default value.
public java.lang.Integer getInteger(java.lang.String name)
getIntObject(java.lang.String, java.lang.Integer)
instead
getInteger
in interface ValueParser
name
- A String with the name.
public int[] getInts(java.lang.String name)
getInts
in interface ValueParser
name
- A String with the name.
public java.lang.Integer getIntObject(java.lang.String name, java.lang.Integer defaultValue)
getIntObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Integer getIntObject(java.lang.String name)
getIntObject
in interface ValueParser
name
- A String with the name.
public java.lang.Integer[] getIntObjects(java.lang.String name)
getIntObjects
in interface ValueParser
name
- A String with the name.
public java.lang.Integer[] getIntegers(java.lang.String name)
getIntObjects(java.lang.String)
instead
getIntegers
in interface ValueParser
name
- A String with the name.
public long getLong(java.lang.String name, long defaultValue)
getLong
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public long getLong(java.lang.String name)
getLong
in interface ValueParser
name
- A String with the name.
public long[] getLongs(java.lang.String name)
getLongs
in interface ValueParser
name
- A String with the name.
public java.lang.Long[] getLongObjects(java.lang.String name)
getLongObjects
in interface ValueParser
name
- A String with the name.
public java.lang.Long getLongObject(java.lang.String name)
getLongObject
in interface ValueParser
name
- A String with the name.
public java.lang.Long getLongObject(java.lang.String name, java.lang.Long defaultValue)
getLongObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public byte getByte(java.lang.String name, byte defaultValue)
getByte
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public byte getByte(java.lang.String name)
getByte
in interface ValueParser
name
- A String with the name.
public byte[] getBytes(java.lang.String name) throws java.io.UnsupportedEncodingException
getBytes
in interface ValueParser
name
- A String with the name.
java.io.UnsupportedEncodingException
public java.lang.Byte getByteObject(java.lang.String name, java.lang.Byte defaultValue)
getByteObject
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public java.lang.Byte getByteObject(java.lang.String name)
getByteObject
in interface ValueParser
name
- A String with the name.
public java.lang.String getString(java.lang.String name)
getString
in interface ValueParser
name
- A String with the name.
public java.lang.String get(java.lang.String name)
$data.Parameters.form_variable_name
get
in interface ValueParser
name
- A String with the name.
public java.lang.String getString(java.lang.String name, java.lang.String defaultValue)
getString
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public void setString(java.lang.String name, java.lang.String value)
setString
in interface ValueParser
name
- The name of the parameter.value
- The value to set.public java.lang.String[] getStrings(java.lang.String name)
getStrings
in interface ValueParser
name
- A String with the name.
public java.lang.String[] getStrings(java.lang.String name, java.lang.String[] defaultValue)
getStrings
in interface ValueParser
name
- A String with the name.defaultValue
- The default value.
public void setStrings(java.lang.String name, java.lang.String[] values)
setStrings
in interface ValueParser
name
- The name of the parameter.values
- The value to set.public java.lang.Object getObject(java.lang.String name)
getObject
in interface ValueParser
name
- A String with the name.
public java.lang.Object[] getObjects(java.lang.String name)
getObjects
in interface ValueParser
name
- A String with the name.
public java.util.Date getDate(java.lang.String name, java.text.DateFormat df, java.util.Date defaultValue)
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.
getDate
in interface ValueParser
name
- A String with the name.df
- A DateFormat.defaultValue
- The default value.
public java.util.Date getDate(java.lang.String name)
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.
getDate
in interface ValueParser
name
- A String with the name.
public java.util.Date getDate(java.lang.String name, java.text.DateFormat df)
Date
object. String is parsed by supplied
DateFormat. If the name does not exist, return null.
getDate
in interface ValueParser
name
- A String with the name.df
- A DateFormat.
public org.apache.torque.om.NumberKey getNumberKey(java.lang.String name)
getNumberKey
in interface ValueParser
name
- A String with the name.
null
if unparsable.public org.apache.torque.om.StringKey getStringKey(java.lang.String name)
getStringKey
in interface ValueParser
name
- A String with the name.
null
if unparsable.public void setProperties(java.lang.Object bean) throws java.lang.Exception
setProperties
in interface ValueParser
bean
- An Object.
java.lang.Exception
- a generic exception.public java.lang.String toString()
toString
in interface ValueParser
protected java.lang.Object[] getToStringParam(java.lang.String name)
name
- A string with the name
protected void setProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop) throws java.lang.Exception
bean
- An Object.prop
- A PropertyDescriptor.
java.lang.Exception
- a generic exception.protected void putParam(java.lang.String name, java.lang.String[] value)
name
- A String with the name.value
- An array of Objects with the values.protected java.lang.String[] getParam(java.lang.String name)
name
- A string with the name
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |