org.apache.tapestry.multipart
Class DefaultMultipartDecoder
java.lang.Object
|
+--org.apache.tapestry.multipart.DefaultMultipartDecoder
- All Implemented Interfaces:
- IMultipartDecoder
- public class DefaultMultipartDecoder
- extends Object
- implements IMultipartDecoder
Decodes the data in a multipart/form-data
HTTP request, handling
file uploads and multi-valued parameters. After decoding, the class is used
to access the parameter values.
This implementation is a thin wrapper around the Apache Jakarta
FileUpload.
Supports single valued parameters, multi-valued parameters and individual
file uploads. That is, for file uploads, each upload must be a unique parameter
(that is all the Upload
component needs).
- Since:
- 2.0.1
- Version:
- $Id: DefaultMultipartDecoder.java,v 1.7 2003/07/03 02:37:14 hlship Exp $
- Author:
- Joe Panico
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PART_MAP_ATTRIBUTE_NAME
public static final String PART_MAP_ATTRIBUTE_NAME
- Request attribute key used to store the part map for this request.
The part map is created in
decode(HttpServletRequest)
. By storing
the part map in the request instead of an instance variable, DefaultMultipartDecoder
becomes threadsafe (no client-specific state in instance variables).
DefaultMultipartDecoder
public DefaultMultipartDecoder()
getSharedInstance
public static DefaultMultipartDecoder getSharedInstance()
setMaxSize
public void setMaxSize(int maxSize)
getMaxSize
public int getMaxSize()
setThresholdSize
public void setThresholdSize(int thresholdSize)
getThresholdSize
public int getThresholdSize()
setRepositoryPath
public void setRepositoryPath(String repositoryPath)
getRepositoryPath
public String getRepositoryPath()
isMultipartRequest
public static boolean isMultipartRequest(HttpServletRequest request)
cleanup
public void cleanup(HttpServletRequest request)
- Invokes
IPart.cleanup()
on each part.
- Specified by:
cleanup
in interface IMultipartDecoder
decode
public void decode(HttpServletRequest request)
- Decodes the request, storing the part map (keyed on query parameter name,
value is
IPart
into the request as an attribute.
- Specified by:
decode
in interface IMultipartDecoder
- Throws:
ApplicationRuntimeException
- if decode fails, for instance the
request exceeds getMaxSize()
getString
public String getString(HttpServletRequest request,
String name)
- Description copied from interface:
IMultipartDecoder
- Returns the single value (or first value) for the parameter
with the specified name. Returns null if no such parameter
was in the request.
- Specified by:
getString
in interface IMultipartDecoder
getStrings
public String[] getStrings(HttpServletRequest request,
String name)
- Description copied from interface:
IMultipartDecoder
- Returns an array of values (possibly a single element array).
Returns null if no such parameter was in the request.
- Specified by:
getStrings
in interface IMultipartDecoder
getUploadFile
public IUploadFile getUploadFile(HttpServletRequest request,
String name)
- Description copied from interface:
IMultipartDecoder
- Returns the uploaded file with the specified parameter name,
or null if no such parameter was in the request.
- Specified by:
getUploadFile
in interface IMultipartDecoder