|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.request.RequestParser
public abstract class RequestParser
Abstract Base Class (ABC) for mapping a request to an Action
.
See the BuildImpl
for important information on how this item is configured.
Almost all concrete implementations of this Abstract Base Class will need to
implement only a single method - getWebAction()
. WEB4J provides a default implementation
RequestParserImpl
.
The role of this class is to view the request at a higher level than the underlying Servlet API. In particular, its services include :
Action
Date
, BigDecimal
and so on, using the configured implementation of
ConvertParam
. (The application programmer will usually use
ModelFromRequest
to build Model Objects.)
File upload parameters are not returned
by this class. Such parameters must be examined in an Action
. The Servlet API
before version 3.0 of the specification has poor support for file upload parameters,
and use of a third party tool is recommended.
The various toXXX methods are offered as a convenience for accessing String
and String-like data. All such toXXX methods apply the filtering (and possible
preprocessing) performed by ConvertParam
.
Constructor Summary | |
---|---|
RequestParser(HttpServletRequest aRequest,
HttpServletResponse aResponse)
Constructor called by subclasses. |
Method Summary | ||
---|---|---|
static RequestParser |
getInstance(HttpServletRequest aRequest,
HttpServletResponse aResponse)
Return the configured concrete instance of this Abstract Base Class. |
|
String |
getRawParamValue(RequestParameter aReqParam)
Return the parameter value exactly as it appears in the request. |
|
String[] |
getRawParamValues(RequestParameter aReqParam)
Return a multi-valued parameter's values exactly as they appear in the request. |
|
HttpServletRequest |
getRequest()
Return the underlying request. |
|
HttpServletResponse |
getResponse()
Return the response associated with the underlying request. |
|
abstract Action |
getWebAction()
Map a given request to a corresponding Action . |
|
boolean |
isFileUploadRequest()
Return true only if the request is a POST, and has content type starting with multipart/form-data. |
|
Id |
toId(RequestParameter aReqParam)
Return a single-valued request parameter as an Id . |
|
Collection<Id> |
toIds(RequestParameter aReqParam)
Return a multi-valued request parameter as a Collection<Id> . |
|
SafeText |
toSafeText(RequestParameter aReqParam)
Return a single-valued request parameter as SafeText . |
|
Collection<SafeText> |
toSafeTexts(RequestParameter aReqParam)
Return a multi-valued request parameter as a Collection<SafeText> . |
|
|
toSupportedObject(RequestParameter aReqParam,
Class<T> aSupportedTargetClass)
Return a building block object. |
|
|
toSupportedObjects(RequestParameter aReqParam,
Class<T> aSupportedTargetClass)
Return an ummodifiable List of building block objects. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RequestParser(HttpServletRequest aRequest, HttpServletResponse aResponse)
Method Detail |
---|
public static RequestParser getInstance(HttpServletRequest aRequest, HttpServletResponse aResponse)
See the BuildImpl
for important information on how
this item is configured.
public abstract Action getWebAction() throws BadRequestException
Action
.
The mapping is determined entirely by concrete subclasses, and must
be implemented by the application programmer. RequestParserImpl
is
provided as a default implementation, and is very likely adequate for most
applications.
If the incoming request does not map to a known Action
, then throw
a BadRequestException
. Such requests
are expected only for bugs and for malicious attacks, and never as part of the normal operation
of the program.
BadRequestException
public final String getRawParamValue(RequestParameter aReqParam)
Can return null values, empty values, values containing only whitespace, and values equal to the IgnorableParamValue configured in web.xml.
public final String[] getRawParamValues(RequestParameter aReqParam)
Can return null values, empty values, values containing only whitespace, and values equal to the IgnorableParamValue configured in web.xml.
public <T> T toSupportedObject(RequestParameter aReqParam, Class<T> aSupportedTargetClass) throws ModelCtorException
Uses all methods of the configured implementation of ConvertParam
.
aReqParam
- underlying request parameteraSupportedTargetClass
- must be supported - see ConvertParam.isSupported(Class)
ModelCtorException
public <T> List<T> toSupportedObjects(RequestParameter aReqParam, Class<T> aSupportedTargetClass) throws ModelCtorException
Uses all methods of the configured implementation of ConvertParam
.
Design Note
List is returned here since HTML specs state that browsers submit param values
in the order of appearance of the corresponding controls in the web page.
aReqParam
- underlying request parameteraSupportedTargetClass
- must be supported - see ConvertParam.isSupported(Class)
ModelCtorException
public final SafeText toSafeText(RequestParameter aReqParam)
SafeText
.
public final Collection<SafeText> toSafeTexts(RequestParameter aReqParam)
Collection<SafeText>
.
public final Id toId(RequestParameter aReqParam)
Id
.
public final Collection<Id> toIds(RequestParameter aReqParam)
Collection<Id>
.
public final HttpServletRequest getRequest()
public final HttpServletResponse getResponse()
public final boolean isFileUploadRequest()
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |