public class RequestBean extends Object implements Request
Request-implementation.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,List<FormUpload>> |
formUploads |
protected String |
host |
protected Map<String,List<String>> |
parameters |
REQUEST_PARSED| Constructor and Description |
|---|
RequestBean() |
RequestBean(long maxSize) |
RequestBean(long maxSize,
File tempDir) |
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(String key,
String value)
Adds the given parameter to this
Request, but only if such a parameter not already exists. |
void |
addParameters(Map<String,String> singleParameters)
Adds the given parameters to this
Request, but only for those parameters not already existsing. |
List<String> |
getAcceptedTypes(String uploadName)
Returns the accepted file-extensions/content-types for the input field with the given name.
|
String |
getEncoding()
Return the encoding for this request
|
Map<String,List<FormUpload>> |
getFormUploads()
Returns all
FormUploads for the request as immutable map. |
List<FormUpload> |
getFormUploads(String name)
Returns an immutable
List of all FormUploads for the parameter with the given name. |
String |
getHost()
Returns the host name for this request
|
javax.servlet.http.HttpServletRequest |
getHttpServletRequest()
Returns the previously processed
HttpServletRequest |
String |
getParameter(String name)
Returns the value for the parameter with the given name.
Note that for a multi-valued parameter, any of the submitted values is returned. |
List<String> |
getParameterList(String name)
Returns a
List containing all the values for the parameter with the given name. |
Set<String> |
getParameterNames()
Returns an immutable
Set containing the names of all request parameters. |
Map<String,String> |
getParameters()
Returns an immutable
Map containing the name of each request-parameter as a key and a single parameter
value as the map's value.Note that for multi-valued parameters, the returned map contains any of the submitted values. |
Map<String,List<String>> |
getParametersList()
Returns an immutable
Map containing the name of each request-parameter as a key and the list of submitted
values as value. |
XSSUtil |
getXssUtil() |
boolean |
hasParameter(String name)
Checks whether a parameter with the given name exists.
|
boolean |
isGet()
Returns
true if this is a HTPP GET request. |
boolean |
isMultiPart()
Returns
true if this is a multipart request. |
boolean |
isPost()
Returns
true if this is a HTPP POST request. |
boolean |
isValid()
Checks whether this is a valid
Request, i.e. |
void |
process(javax.servlet.http.HttpServletRequest servletRequest)
Processes the given
HttpServletRequest. |
void |
setAcceptedTypes(String uploadName,
String... types)
Sets the accepted mime-types or filetype-extensions for the given field
|
void |
setEncoding(String encoding)
Sets the encoding for this request
|
void |
setHost(String host) |
void |
setMaxSize(long maxSize)
Sets the maximum size for a
FormUpload within this Request. |
void |
setMaxSize(long maxSize,
boolean isStrict)
Sets the maximum size for a
FormUpload within this Request, and additionally defines if
violations should be handled strict. |
void |
setTempDir(File tempDir)
Sets the (absolute) temporary directory for storing
FormUploads. |
void |
setXssUtil(XSSUtil xssUtil) |
protected Map<String,List<FormUpload>> formUploads
protected String host
public RequestBean()
public RequestBean(long maxSize)
public RequestBean(long maxSize,
File tempDir)
public List<FormUpload> getFormUploads(String name)
RequestContainerList of all FormUploads for the parameter with the given name.getFormUploads in interface RequestContainername - the name of the parametersFormUploads (never null, but may be empty)public void process(javax.servlet.http.HttpServletRequest servletRequest)
RequestHttpServletRequest. Must only be called once per HttpServletRequest.public String getEncoding()
RequestgetEncoding in interface Requestpublic void setEncoding(String encoding)
RequestsetEncoding in interface Requestencoding - the encodingpublic boolean isMultiPart()
Requesttrue if this is a multipart request.isMultiPart in interface Requesttrue if this is a multipart request, false otherwisepublic boolean isPost()
Requesttrue if this is a HTPP POST request.public boolean isGet()
Requesttrue if this is a HTPP GET request.public void setTempDir(File tempDir)
RequestFormUploads. Note that, if not set or not existent,
the directory specified by the System propertey java.io.tmpdir is used.setTempDir in interface RequesttempDir - the directory for storing FormUploadspublic void setMaxSize(long maxSize)
RequestFormUpload within this Request.setMaxSize in interface RequestmaxSize - the maximum size of a FormUploadFormUpload.getMaxSize()public void setMaxSize(long maxSize,
boolean isStrict)
RequestFormUpload within this Request, and additionally defines if
violations should be handled strict.setMaxSize in interface RequestmaxSize - the maximum size of a FormUploadisStrict - if set to true, and a FormUpload exceeds the given size, the whole Request
will be marked as invalid.Request.isValid()public void setAcceptedTypes(String uploadName, String... types)
RequestsetAcceptedTypes in interface RequestuploadName - the name of the input-field (type="file")types - the accepted mimetypes (e.g. image/jpeg, image/png) or file extensions (e.g jgp,png), those can be
used in combinationpublic List<String> getAcceptedTypes(String uploadName)
RequestgetAcceptedTypes in interface RequestuploadName - the name of the input fieldFormUpload.getAcceptedTypes()public boolean isValid()
RequestRequest, i.e. no Exception occurred during
Request.process(HttpServletRequest).public javax.servlet.http.HttpServletRequest getHttpServletRequest()
RequestHttpServletRequestgetHttpServletRequest in interface RequestHttpServletRequestpublic void addParameter(String key, String value)
RequestRequest, but only if such a parameter not already exists. This prevents
overwriting a parameter which is already present in the original HttpServletRequest.addParameter in interface Requestkey - the parameter namevalue - the parameter valuepublic void addParameters(Map<String,String> singleParameters)
RequestRequest, but only for those parameters not already existsing. This
prevents overwriting a parameter which is already present in the original HttpServletRequest. The given
Map uses the parameter name as the key and the parameter value as the value.addParameters in interface RequestsingleParameters - the parameters to addRequest.addParameter(String, String),
RequestContainer.getParameter(String)public Map<String,List<FormUpload>> getFormUploads()
RequestContainerFormUploads for the request as immutable map. Returns a Map using the parameters name
as a key and a List of FormUploads as the value.getFormUploads in interface RequestContainerMap containing the FileUploadspublic String getHost()
RequestContainergetHost in interface RequestContainerpublic String getParameter(String name)
RequestContainerRequestContainer.getParameterList(String) instead if you want to deal with a multi-valued parameter.getParameter in interface RequestContainername - the name of the parameterpublic List<String> getParameterList(String name)
RequestContainerList containing all the values for the parameter with the given name.getParameterList in interface RequestContainername - the name of the parameterList (never null, but may be empty) containing all the values for the given parameterpublic Set<String> getParameterNames()
RequestContainerSet containing the names of all request parameters.getParameterNames in interface RequestContainerpublic Map<String,String> getParameters()
RequestContainerMap containing the name of each request-parameter as a key and a single parameter
value as the map's value.RequestContainer.getParametersList() instead if you want to deal with multi-valued parameters.getParameters in interface RequestContainerMap containing the request parameterspublic Map<String,List<String>> getParametersList()
RequestContainerMap containing the name of each request-parameter as a key and the list of submitted
values as value.getParametersList in interface RequestContainerMap containing the request parameters (including multi-valued ones)public boolean hasParameter(String name)
RequestContainerhasParameter in interface RequestContainername - the name of the parametertrue if such a parameter exists, false otherwisepublic void setHost(String host)
public XSSUtil getXssUtil()
public void setXssUtil(XSSUtil xssUtil)
Copyright © 2011–2019 aiticon GmbH. All rights reserved.