Expresso 5-6

com.jcorporate.expresso.core.misc.upload
Class DefaultParameterParser

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.upload.BaseValueParser
      extended bycom.jcorporate.expresso.core.misc.upload.DefaultParameterParser
All Implemented Interfaces:
ParameterParser, ValueParser

public class DefaultParameterParser
extends BaseValueParser
implements ParameterParser

DefaultParameterParser is a utility object to handle parsing and retrieving the data passed via the GET/POST/PATH_INFO arguments.

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:

 ParameterParser pp = data.getParameters();
 pp.add("ERROR",1);
 pp.add("eRrOr",2);
 int result = pp.getInt("ERROR");
 

In the above example, result is 2.

Version:
$Id: DefaultParameterParser.java,v 1.6 2004/11/17 20:48:13 lhamel Exp $
Author:
Ilkka Priha, Jon S. Stevens, Sean Legassick

Field Summary
 
Fields inherited from class com.jcorporate.expresso.core.misc.upload.BaseValueParser
parameters
 
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
DefaultParameterParser()
          Create a new empty instance of ParameterParser.
DefaultParameterParser(String characterEncoding)
          Create a new empty instance of ParameterParser.
 
Method Summary
 void append(String name, FileItem value)
          Add a FileItem object as a parameters.
 void dispose()
          Disposes the parser.
 FileItem getFileItem(String name)
          Return a FileItem object for the given name.
 FileItem[] getFileItems(String name)
          Return an array of FileItem objects for the given name.
 HttpServletRequest getRequest()
          Gets the parsed servlet request.
 boolean hasFileItem(String paramName)
           
 void setRequest(HttpServletRequest req)
          Sets the servlet request to be parser.
 byte[] setUploadData()
          Gets the uploadData byte[]
 void setUploadData(byte[] uploadData)
          Sets the uploadData byte[]
 
Methods inherited from class com.jcorporate.expresso.core.misc.upload.BaseValueParser
add, add, add, add, add, append, clear, containsKey, convert, convertAndTrim, get, getBigDecimal, getBigDecimal, getBigDecimals, getBool, getBool, getBoolean, getBoolean, getByte, getByte, getBytes, getCharacterEncoding, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getInteger, getInteger, getInteger, getIntegers, getInts, getKeys, getLong, getLong, getLongObjects, getLongs, getObject, getObjects, getString, getString, getStrings, getStrings, keys, remove, setCharacterEncoding, setProperties, setString, setStrings, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jcorporate.expresso.core.misc.upload.ValueParser
add, add, add, add, add, append, clear, containsKey, convert, get, getBigDecimal, getBigDecimal, getBigDecimals, getBool, getBool, getBoolean, getBoolean, getByte, getByte, getBytes, getCharacterEncoding, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getInteger, getInteger, getInteger, getIntegers, getInts, getKeys, getLong, getLong, getLongObjects, getLongs, getObject, getObjects, getString, getString, getStrings, getStrings, keys, remove, setCharacterEncoding, setProperties, setString, setStrings, toString
 

Constructor Detail

DefaultParameterParser

public DefaultParameterParser()
Create a new empty instance of ParameterParser. Uses the default character encoding (US-ASCII).

To add name/value pairs to this set of parameters, use the add() methods.


DefaultParameterParser

public DefaultParameterParser(String characterEncoding)
Create a new empty instance of ParameterParser. Takes a character encoding name to use when converting strings to bytes.

To add name/value pairs to this set of parameters, use the add() methods.

Parameters:
characterEncoding - The character encoding of strings.
Method Detail

hasFileItem

public boolean hasFileItem(String paramName)

dispose

public void dispose()
Disposes the parser.

Overrides:
dispose in class BaseValueParser

getRequest

public HttpServletRequest getRequest()
Gets the parsed servlet request.

Specified by:
getRequest in interface ParameterParser
Returns:
the parsed servlet request or null.

setRequest

public void setRequest(HttpServletRequest req)
Description copied from interface: ParameterParser
Sets the servlet request to be parser. This requires a valid HttpServletRequest object. It will attempt to parse out the GET/POST/PATH_INFO data and store the data into a Hashtable. There are convenience methods for retrieving the data as a number of different datatypes. The PATH_INFO data must be a URLEncoded() string.

To add name/value pairs to this set of parameters, use the add() methods.

Specified by:
setRequest in interface ParameterParser
Parameters:
req - An HttpServletRequest.

setUploadData

public void setUploadData(byte[] uploadData)
Sets the uploadData byte[]

Specified by:
setUploadData in interface ParameterParser
Parameters:
uploadData - A byte[] with data.

setUploadData

public byte[] setUploadData()
Gets the uploadData byte[]

Specified by:
setUploadData in interface ParameterParser
Returns:
uploadData A byte[] with data.

append

public void append(String name,
                   FileItem value)
Add a FileItem object as a parameters. If there are any FileItems already associated with the name, append to the array. The reason for this is that RFC 1867 allows multiple files to be associated with single HTML input element.

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

getFileItem

public FileItem getFileItem(String name)
Return a FileItem object for the given name. If the name does not exist or the object stored is not a FileItem, return null.

Specified by:
getFileItem in interface ParameterParser
Parameters:
name - A String with the name.
Returns:
A FileItem.

getFileItems

public FileItem[] getFileItems(String name)
Return an array of FileItem objects for the given name. If the name does not exist or the object stored is not a FileItem array, return null.

Specified by:
getFileItems in interface ParameterParser
Parameters:
name - A String with the name.
Returns:
A FileItem[].

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.