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. |
void |
addParameters(String key,
List<String> values)
Adds the given parameters to this
Request , but only if such a parameter not already exists. |
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
FormUpload s for the request as immutable map. |
List<FormUpload> |
getFormUploads(String name)
Returns an immutable
List of all FormUpload s 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
FormUpload s. |
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)
RequestContainer
List
of all FormUpload
s for the parameter with the given name.getFormUploads
in interface RequestContainer
name
- the name of the parametersFormUpload
s (never null
, but may be empty)public void process(javax.servlet.http.HttpServletRequest servletRequest)
Request
HttpServletRequest
. Must only be called once per HttpServletRequest
.public String getEncoding()
Request
getEncoding
in interface Request
public void setEncoding(String encoding)
Request
setEncoding
in interface Request
encoding
- the encodingpublic boolean isMultiPart()
Request
true
if this is a multipart request.isMultiPart
in interface Request
true
if this is a multipart request, false
otherwisepublic boolean isPost()
Request
true
if this is a HTPP POST request.public boolean isGet()
Request
true
if this is a HTPP GET request.public void setTempDir(File tempDir)
Request
FormUpload
s. Note that, if not set or not existent,
the directory specified by the System
propertey java.io.tmpdir
is used.setTempDir
in interface Request
tempDir
- the directory for storing FormUpload
spublic void setMaxSize(long maxSize)
Request
FormUpload
within this Request
.setMaxSize
in interface Request
maxSize
- the maximum size of a FormUpload
FormUpload.getMaxSize()
public void setMaxSize(long maxSize, boolean isStrict)
Request
FormUpload
within this Request
, and additionally defines if
violations should be handled strict.setMaxSize
in interface Request
maxSize
- the maximum size of a FormUpload
isStrict
- 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)
Request
setAcceptedTypes
in interface Request
uploadName
- 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)
Request
getAcceptedTypes
in interface Request
uploadName
- the name of the input fieldFormUpload.getAcceptedTypes()
public boolean isValid()
Request
Request
, i.e. no Exception
occurred during
Request.process(HttpServletRequest)
.public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Request
HttpServletRequest
getHttpServletRequest
in interface Request
HttpServletRequest
public void addParameter(String key, String value)
Request
Request
, 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 Request
key
- the parameter namevalue
- the parameter valuepublic void addParameters(String key, List<String> values)
Request
Request
, but only if such a parameter not already exists. This prevents
overwriting a parameter which is already present in the original HttpServletRequest
.addParameters
in interface Request
key
- the parameter namevalues
- the parameter valuespublic void addParameters(Map<String,String> singleParameters)
Request
Request
, 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 Request
singleParameters
- the parameters to addRequest.addParameter(String, String)
,
RequestContainer.getParameter(String)
public Map<String,List<FormUpload>> getFormUploads()
RequestContainer
FormUpload
s for the request as immutable map. Returns a Map
using the parameters name
as a key and a List
of FormUpload
s as the value.getFormUploads
in interface RequestContainer
Map
containing the FileUpload
spublic String getHost()
RequestContainer
getHost
in interface RequestContainer
public String getParameter(String name)
RequestContainer
RequestContainer.getParameterList(String)
instead if you want to deal with a multi-valued parameter.getParameter
in interface RequestContainer
name
- the name of the parameterpublic List<String> getParameterList(String name)
RequestContainer
List
containing all the values for the parameter with the given name.getParameterList
in interface RequestContainer
name
- the name of the parameterList
(never null
, but may be empty) containing all the values for the given parameterpublic Set<String> getParameterNames()
RequestContainer
Set
containing the names of all request parameters.getParameterNames
in interface RequestContainer
public Map<String,String> getParameters()
RequestContainer
Map
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 RequestContainer
Map
containing the request parameterspublic Map<String,List<String>> getParametersList()
RequestContainer
Map
containing the name of each request-parameter as a key and the list of submitted
values as value.getParametersList
in interface RequestContainer
Map
containing the request parameters (including multi-valued ones)public boolean hasParameter(String name)
RequestContainer
hasParameter
in interface RequestContainer
name
- 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–2023 aiticon GmbH. All rights reserved.