org.codehaus.plexus.summit.parameters
Class BaseRequestParameterParser
java.lang.Object
org.codehaus.plexus.logging.AbstractLogEnabled
org.codehaus.plexus.summit.parameters.BaseRequestParameterParser
- All Implemented Interfaces:
- org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable, org.codehaus.plexus.logging.LogEnabled, RequestParameterParser
- Direct Known Subclasses:
- SummitRequestParameterParser
- public class BaseRequestParameterParser
- extends org.codehaus.plexus.logging.AbstractLogEnabled
- implements RequestParameterParser, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
Default implementation of a RequestParameterParser. This
implementation uses the standard servlet method of parsing query info
and post data to assemble a parameter map. In addition, any file uploads
are processed and are made available via the returned RequestParameters
object.
This component is thread-safe.
- Author:
- Ilkka Priha, Jon S. Stevens, Sean Legassick, Pete Kazmier
Method Summary |
protected void |
addFileItem(java.util.Map parameterMap,
java.lang.String name,
org.apache.commons.fileupload.FileItem item)
Add a FileItem to the specified parameter map ensuring that
the value is stored as an array of FileItems even if there
is only a single parameter. |
protected void |
addParameter(java.util.Map parameterMap,
java.lang.String name,
java.lang.String value)
Add a parameter to the specified parameter map ensuring that the value
is stored as an array of Strings even if there is only a
single parameter. |
protected void |
doParse(javax.servlet.http.HttpServletRequest request,
java.util.Map parameterMap)
Invoked as part of the parse template method to provide a
hook for additional parsing of parameters. |
void |
initialize()
|
RequestParameters |
parse(javax.servlet.http.HttpServletRequest request)
Parses the query info for the parameters associated with this
request as well as any uploaded files sent with the HTTP request. |
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BaseRequestParameterParser
public BaseRequestParameterParser()
initialize
public void initialize()
throws org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
- Specified by:
initialize
in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
- Throws:
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
parse
public RequestParameters parse(javax.servlet.http.HttpServletRequest request)
- Parses the query info for the parameters associated with this
request as well as any uploaded files sent with the HTTP request.
Note: This parser does not inspect the path info for name/value
pairs as the Turbine does. If you want the path info parsed for
parameters, use the
SummitRequestParameterParser
instead.
Implementation note: This method is a template method and provides
a hook that implementors may use for additional parsing of the
request. This method does the following:
- Processes any file upload requests.
- Parses the query info for parameters.
- Invokes doParse which may be implemented by
subclasses to do additional processing on the request.
- Returns the parameter map wrapped in a RequestParameter
object.
- Specified by:
parse
in interface RequestParameterParser
- Parameters:
request
- The HTTP request to parse for parameters.
- Returns:
- RequestParameters The requested parameters wrapped in
a RequestParameters object for easy access to the parameters.
- See Also:
RequestParameterParser.parse(javax.servlet.http.HttpServletRequest)
doParse
protected void doParse(javax.servlet.http.HttpServletRequest request,
java.util.Map parameterMap)
- Invoked as part of the parse template method to provide a
hook for additional parsing of parameters. The HTTP request is
passed as an argument as well as a map which is acting as a collector
argument. The map contains name/value pairs where each name is a
String representing the parameter name, and the value is an
array of either Strings or FileItems representing
the value of the parameter. Note: the value must be an array
even if there is only a single value.
- Parameters:
request
- The HTTP request to parse for parameters.parameterMap
- A map of the collected parameters which should
be used to store additional parameters in the format described above.
A helper method has been provided to ensure the values are stored
as arrays (see addParameter).
addFileItem
protected void addFileItem(java.util.Map parameterMap,
java.lang.String name,
org.apache.commons.fileupload.FileItem item)
- Add a FileItem to the specified parameter map ensuring that
the value is stored as an array of FileItems even if there
is only a single parameter.
- Parameters:
parameterMap
- The map which the parameter should be added.name
- The name of the parameter.item
- The file item associated with the parameter.
addParameter
protected void addParameter(java.util.Map parameterMap,
java.lang.String name,
java.lang.String value)
- Add a parameter to the specified parameter map ensuring that the value
is stored as an array of Strings even if there is only a
single parameter.
- Parameters:
parameterMap
- The map which the parameter should be added.name
- The name of the parameter.value
- The value of the parameter.
Copyright © 2001-2007 Codehaus. All Rights Reserved.