Package org.apache.fulcrum.parser
Interface ValueParser
- All Known Subinterfaces:
- CookieParser,- ParameterParser
- All Known Implementing Classes:
- BaseValueParser,- DefaultCookieParser,- DefaultParameterParser,- StringValueParser
ValueParser is a base interface for classes that need to parse
 name/value Parameters, for example GET/POST data or Cookies
 (ParameterParser and CookieParser)
 
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:
- Version:
- $Id$
- Author:
- Ilkka Priha, Jon S. Stevens, Sean Legassick, Jason van Zyl, Jürgen Hoffmann, Thomas Vandahl
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumPossible values for the URL folding setting
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe default character encoding to use when converting to byte arrays
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd a name/value pair into this object.voidAdd a name/value pair into this object.voidAdd a name/value pair into this object.voidAdd a name/value pair into this object.voidAdd a name/value pair into this object.voidAdd an array of Strings for a key.voidclear()Clear all name/value pairs out of this object.booleancontainsKey(Object key) Determine whether a given key has been inserted.Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING.convertAndTrim(String value) Convert a String value according to the url-case-folding property.convertAndTrim(String value, ValueParser.URLCaseFolding folding) 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.voiddispose()Dispose all references of this object.Return a String for the given name.getBigDecimal(String name) Return a BigDecimal for the given name.getBigDecimal(String name, BigDecimal defaultValue) Return a BigDecimal for the given name.getBigDecimals(String name) Return an array of BigDecimals for the given name.booleangetBoolean(String name) Return a boolean for the given name.booleangetBoolean(String name, boolean defaultValue) Return a boolean for the given name.getBooleanObject(String name) Returns a Boolean object for the given name.getBooleanObject(String name, Boolean defaultValue) Returns a Boolean object for the given name.Boolean[]getBooleanObjects(String name) Return an array of Booleans for the given name.boolean[]getBooleans(String name) Return an array of booleans for the given name.byteReturn a byte for the given name.byteReturn a byte for the given name.getByteObject(String name) Return a byte for the given name.getByteObject(String name, Byte defaultValue) Return a byte for the given name.byte[]Return an array of bytes for the given name.Get the character encoding that will be used by this ValueParser.Returns a java.util.Date object.getDate(String name, DateFormat df) Returns a java.util.Date object.getDate(String name, DateFormat df, Date defaultValue) Returns a java.util.Date object.Get the date format that will be used by this ValueParser.doubleReturn a double for the given name.doubleReturn a double for the given name.getDoubleObject(String name) Return a Double for the given name.getDoubleObject(String name, Double defaultValue) Return a Double for the given name.Double[]getDoubleObjects(String name) Return an array of doubles for the given name.double[]getDoubles(String name) Return an array of doubles for the given name.floatReturn a float for the given name.floatReturn a float for the given name.getFloatObject(String name) Return a float for the given name.getFloatObject(String name, Float defaultValue) Return a Float for the given name.Float[]getFloatObjects(String name) Return an array of floats for the given name.float[]Return an array of floats for the given name.intReturn an int for the given name.intReturn an int for the given name.getIntObject(String name) Return an Integer for the given name.getIntObject(String name, Integer defaultValue) Return an Integer for the given name.Integer[]getIntObjects(String name) Return an array of Integers for the given name.int[]Return an array of ints for the given name.String[]getKeys()Returns all the available parameter names.Get the locale that will be used by this ValueParser.longReturn a long for the given name.longReturn a long for the given name.getLongObject(String name) Return a Long for the given name.getLongObject(String name, Long defaultValue) Return a Long for the given name.Long[]getLongObjects(String name) Return an array of Longs for the given name.long[]Return an array of longs for the given name.Get the number format that will be used by this ValueParser.Return an Object for the given name.Object[]getObjects(String name) Return an array of Objects for the given name.Return a String for the given name.Return a String for the given name.String[]getStrings(String name) Return an array of Strings for the given name.String[]getStrings(String name, String[] defaultValue) Return an array of Strings for the given name.Gets the folding value from the ParserService configurationkeySet()Gets the keys.Removes the named parameter from the contained hashtable.voidsetCharacterEncoding(String characterEncoding) Set the character encoding that will be used by this ValueParser.voidsetDateFormat(DateFormat dateFormat) Set the date format that will be used by this ValueParser.voidSet the locale that will be used by this ValueParser.voidsetNumberFormat(NumberFormat numberFormat) Set the number format that will be used by this ValueParser.voidsetProperties(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.voidSet a parameter to a specific value.voidsetStrings(String name, String[] values) Set a parameter to a specific value.toString()Simple method that attempts to get a toString() representation of this object.Methods inherited from interface java.lang.IterableforEach, iterator, spliterator
- 
Field Details- 
DEFAULT_CHARACTER_ENCODINGThe default character encoding to use when converting to byte arrays- See Also:
 
 
- 
- 
Method Details- 
clearvoid clear()Clear all name/value pairs out of this object.
- 
disposevoid dispose()Dispose all references of this object. Instead of org.apache.fulcrum.pool.Recyclable interface we use this, may change this again..
- 
setCharacterEncodingSet the character encoding that will be used by this ValueParser.- Parameters:
- characterEncoding- the character encoding to use
 
- 
getCharacterEncodingString getCharacterEncoding()Get the character encoding that will be used by this ValueParser.- Returns:
- Current character encoding
 
- 
setLocaleSet the locale that will be used by this ValueParser.- Parameters:
- locale- the default locale to be used by the parser
 
- 
getLocaleLocale getLocale()Get the locale that will be used by this ValueParser.- Returns:
- Locale the locale being used
 
- 
setDateFormatSet the date format that will be used by this ValueParser.- Parameters:
- dateFormat- the date format
 
- 
getDateFormatDateFormat getDateFormat()Get the date format that will be used by this ValueParser.- Returns:
- DateFormat current date format used by this ValueParser
 
- 
setNumberFormatSet the number format that will be used by this ValueParser.- Parameters:
- numberFormat- the number format to use
 
- 
getNumberFormatNumberFormat getNumberFormat()Get the number format that will be used by this ValueParser.- Returns:
- NumberFormat the current number format
 
- 
convertTrims 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.
 
- 
addAdd a name/value pair into this object.- Parameters:
- name- A String with the name.
- value- A double with the value.
 
- 
addAdd a name/value pair into this object.- Parameters:
- name- A String with the name.
- value- An int with the value.
 
- 
addAdd a name/value pair into this object.- Parameters:
- name- A String with the name.
- value- An Integer with the value.
 
- 
addAdd a name/value pair into this object.- Parameters:
- name- A String with the name.
- value- A long with the value.
 
- 
addAdd a name/value pair into this object.- Parameters:
- name- A String with the name.
- value- A long with the value.
 
- 
addAdd an array of Strings for a key. This is simply adding all the elements in the array one by one.- Parameters:
- name- A String with the name.
- value- A String Array.
 
- 
removeRemoves the named parameter from the contained hashtable. Wraps to the containedHashtable.remove().- Parameters:
- name- the name of the mapped value to remove
- Returns:
- The value that was mapped to the key (a String[]) ornullif the key was not mapped.
 
- 
containsKeyDetermine 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.
- Returns:
- True if the object is found.
 
- 
keySetGets the keys.- Returns:
- A Setof the keys.
 
- 
getKeysString[] getKeys()Returns all the available parameter names.- Returns:
- A object array with the keys.
 
- 
getBooleanReturn a boolean for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A boolean.
 
- 
getBooleanReturn a boolean for the given name. If the name does not exist, return false.- Parameters:
- name- A String with the name.
- Returns:
- A boolean.
 
- 
getBooleanObjectReturns 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. - Parameters:
- name- A String with the name.
- Returns:
- A Boolean.
 
- 
getBooleanObjectReturns a Boolean object for the given name. If the parameter does not exist or can not be parsed as a boolean, the defaultValue is returned.Valid values for true: true, on, 1, yes 
 Valid values for false: false, off, 0, no
 The string is compared without regard to case. - Parameters:
- name- A String with the name.
- defaultValue- boolean default if not found
- Returns:
- A Boolean.
 
- 
getBooleansReturn an array of booleans for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A boolean[].
 
- 
getBooleanObjectsReturn an array of Booleans for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A Boolean[].
 
- 
getDoubleReturn a double for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A double.
 
- 
getDoubleReturn a double for the given name. If the name does not exist, return 0.0.- Parameters:
- name- A String with the name.
- Returns:
- A double.
 
- 
getDoublesReturn an array of doubles for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A double[].
 
- 
getDoubleObjectReturn a Double for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A double.
 
- 
getDoubleObjectReturn a Double for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A double.
 
- 
getDoubleObjectsReturn an array of doubles for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A double[].
 
- 
getFloatReturn a float for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A float.
 
- 
getFloatReturn a float for the given name. If the name does not exist, return 0.0.- Parameters:
- name- A String with the name.
- Returns:
- A float.
 
- 
getFloatsReturn an array of floats for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A float[].
 
- 
getFloatObjectReturn a Float for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A Float.
 
- 
getFloatObjectReturn a float for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A Float.
 
- 
getFloatObjectsReturn an array of floats for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A float[].
 
- 
getBigDecimalReturn a BigDecimal for the given name. If the name does not exist, return 0.0.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A BigDecimal.
 
- 
getBigDecimalReturn a BigDecimal for the given name. If the name does not exist, returnnull.- Parameters:
- name- A String with the name.
- Returns:
- A BigDecimal.
 
- 
getBigDecimalsReturn an array of BigDecimals for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A BigDecimal[].
 
- 
getIntReturn an int for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- An int.
 
- 
getIntReturn an int for the given name. If the name does not exist, return 0.- Parameters:
- name- A String with the name.
- Returns:
- An int.
 
- 
getIntObjectReturn an Integer for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- An Integer.
 
- 
getIntObjectReturn an Integer for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- An Integer.
 
- 
getIntsReturn an array of ints for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- An int[].
 
- 
getIntObjectsReturn an array of Integers for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- An Integer[].
 
- 
getLongReturn a long for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A long.
 
- 
getLongReturn a long for the given name. If the name does not exist, return 0.- Parameters:
- name- A String with the name.
- Returns:
- A long.
 
- 
getLongObjectReturn a Long for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A Long.
 
- 
getLongObjectReturn a Long for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A Long.
 
- 
getLongsReturn an array of longs for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A long[].
 
- 
getLongObjectsReturn an array of Longs for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A Long[].
 
- 
getByteReturn a byte for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A byte.
 
- 
getByteReturn a byte for the given name. If the name does not exist, return 0.- Parameters:
- name- A String with the name.
- Returns:
- A byte.
 
- 
getBytesReturn 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.
- Returns:
- A byte[].
- Throws:
- UnsupportedEncodingException- Generic exception
 
- 
getByteObjectReturn a byte for the given name. If the name does not exist, return defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A byte.
 
- 
getByteObjectReturn a byte for the given name. If the name does not exist, return 0.- Parameters:
- name- A String with the name.
- Returns:
- A byte.
 
- 
getStringReturn a String for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A String.
 
- 
getReturn 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.
- Returns:
- A String.
 
- 
getStringReturn a String for the given name. If the name does not exist, return the defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A String.
 
- 
setStringSet 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.
- value- The value to set.
 
- 
getStringsReturn an array of Strings for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- A String[].
 
- 
getStringsReturn an array of Strings for the given name. If the name does not exist, return the defaultValue.- Parameters:
- name- A String with the name.
- defaultValue- The default value.
- Returns:
- A String[].
 
- 
setStringsSet 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.
- values- The value to set.
 
- 
getObjectReturn an Object for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- An Object.
 
- 
getObjectsReturn an array of Objects for the given name. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- Returns:
- An Object[].
 
- 
getDateReturns a java.util.Date object. String is parsed by supplied DateFormat. If the name does not exist, return the defaultValue.- Parameters:
- name- A String with the name.
- df- A DateFormat.
- defaultValue- The default value.
- Returns:
- A Date.
 
- 
getDateReturns a java.util.Date object. If there are DateSelector 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.- Parameters:
- name- A String with the name.
- Returns:
- A Date.
 
- 
getDateReturns a java.util.Date object. String is parsed by supplied DateFormat. If the name does not exist, return null.- Parameters:
- name- A String with the name.
- df- A DateFormat.
- Returns:
- A Date.
 
- 
setPropertiesUses 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.
 
- 
toStringString toString()Simple method that attempts to get a toString() representation of this object. It doesn't do well with String[]'s though.
- 
convertAndTrimConvert a String value according to the url-case-folding property.- Parameters:
- value- the String to convert
- Returns:
- a new String.
 
- 
convertAndTrimA 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.
- folding- the type of URL case folding to be used
- Returns:
- A new String converted and trimmed.
 
- 
getUrlFoldingValueParser.URLCaseFolding getUrlFolding()Gets the folding value from the ParserService configuration- Returns:
- The current Folding Value
 
 
-