|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
org.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper
org.barracudamvc.core.helper.servlet.MultipartRequestWrapper
public class MultipartRequestWrapper
Handles both simple and multipart requests transparently
For handling multipart stuff, Jakarta Commons Fileupload is used. Otherwise this wrapper's behavior is identical to the superclass. getFileItem* methods are provided to get direct access to file items in a multipart request and an isMultipart() method is provided for querying whether the current request has multipart data in it or not. The only drawback to using this wrapper is the slight overhead involved in doing multipart checks when the request isn't multipart. The performance deficit should, however, be neglegible.
Field Summary | |
---|---|
protected boolean |
isMultipart
indicates if the current request is multipart |
protected long |
maxSize
maximum allowed size of uploads |
protected List |
uploadItemList
contains a list of file items |
Fields inherited from class org.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper |
---|
DEFAULT_ENCODING |
Fields inherited from interface javax.servlet.http.HttpServletRequest |
---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
Constructor Summary | |
---|---|
MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req)
Simple constructor, accepts any file size and uses the default FileItemFactory |
|
MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req,
long max)
|
|
MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req,
long max,
org.apache.commons.fileupload.FileItemFactory fileItemFactory)
Checks if request is multipart. |
Method Summary | |
---|---|
org.apache.commons.fileupload.FileItem |
getFileItem(String name)
Finds a matching item in uploadItems and returns it. |
Enumeration |
getFileParameterNames()
Akin to getParameterNames(), except that only parameter names representing file parameters are applicable here. |
String |
getParameter(String name)
Same behavior as ServletRequest.getParameter, but extended to handle parameters when request is multipart. |
Map |
getParameterMap()
Same behavior as ServletRequest.getParameterMap, but extended to handle parameters when request is multipart. |
Enumeration |
getParameterNames()
Same behavior as ServletRequest.getParameterNames, but extended to handle parameter names when request is multipart. |
String[] |
getParameterValues(String name)
Same behavior as ServletRequest.getParameterValues, but extended to handle parameters when request is multipart. |
protected String |
getUploadItemValueByName(String name)
Finds a matching item in uploadItems and returns its value as a string. |
boolean |
isMultipart()
Specifies whether the current request is multipart |
Methods inherited from class org.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper |
---|
addParameter, getCoreRequest, getMethod, removeAllParameters, removeParameter, resetParameters, setMethod, setRequest |
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper |
---|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole |
Methods inherited from class javax.servlet.ServletRequestWrapper |
---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.http.HttpServletRequest |
---|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole |
Methods inherited from interface javax.servlet.ServletRequest |
---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
Field Detail |
---|
protected long maxSize
protected boolean isMultipart
protected List uploadItemList
file items
Constructor Detail |
---|
public MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req, long max, org.apache.commons.fileupload.FileItemFactory fileItemFactory)
req
- the requestmax
- the maximum allowed size of uploads, -1 signifies no limitfileItemFactory
- some FileItemFactory implementation, defaults to DiskFileItemFactory if nullpublic MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req, long max)
req
- the requestmax
- Maximum allowed size of uploads#this(HttpServletRequest, long, FileItemFactory)
public MultipartRequestWrapper(javax.servlet.http.HttpServletRequest req)
req
- #this(HttpServletRequest, long, FileItemFactory)
Method Detail |
---|
public String getParameter(String name)
getParameter
in interface javax.servlet.ServletRequest
getParameter
in class DefaultServletRequestWrapper
name
- a String specifying the name of the parameter
ServletRequest.getParameter(String)
public Enumeration getParameterNames()
getParameterNames
in interface javax.servlet.ServletRequest
getParameterNames
in class DefaultServletRequestWrapper
ServletRequest.getParameterNames()
public Enumeration getFileParameterNames()
getParameterNames()
public String[] getParameterValues(String name)
getParameterValues
in interface javax.servlet.ServletRequest
getParameterValues
in class DefaultServletRequestWrapper
name
- a String containing the name of the parameter whose value is requested
ServletRequest.getParameterValues(String)
public Map getParameterMap()
getParameterMap
in interface javax.servlet.ServletRequest
getParameterMap
in class DefaultServletRequestWrapper
ServletRequest.getParameterMap()
protected String getUploadItemValueByName(String name)
name
- a String specifying the name of the parameter
getFileItem(String)
,
FileItem.getString(String)
public org.apache.commons.fileupload.FileItem getFileItem(String name)
name
- a String specifying the name of the parameter
public boolean isMultipart()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |