|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.request.RequestParameter
public final class RequestParameter
Request parameter as a name and (usually) an associated regular expression.
This class does not directly provide access to the parameter value.
For such services, please see RequestParser
and ModelFromRequest
.
This class separates request parameters into two kinds : file upload request parameters, and all others (here called "regular" request parameters).
Regular Request Parameters
Regular request parameters are associated with :
ApplicationFirewall
to perform
hard validation
File Upload Request Parameters
Files are uploaded using forms having :
In addition, note that the Servlet API does not have extensive services for processing file upload parameters. It is likely best to use a third party tool for that task.
File upload request parameters, as represented by this class, have only a name associated with them, and no regular expression. This is because WEB4J cannot perform hard validation on the value of a file upload parameter - since the user may select any file whatsoever, validation of file contents can only be treated as a soft validation. If there is a problem, the response to the user must be polished, as part of the normal operation of the application.
As an example, an Action
might perform
soft validation on a file upload parameter
for these items :
Naming Convention
Parameter names are usually not arbitrary in WEB4J.
Instead, a simple convention is used which allows for automated mapping between
request parameter names and corresponding getXXX methods of Model Objects
(see Populate
). For example, a parameter
named 'Birth Date' (or 'birthDate') is mapped to a method named
getBirthDate() when prepopulating a form with the contents of
a Model Object. (The 'Birth Date' naming style is recommended, since it
has this advantage : when messages regarding form input are presented to the user,
the control name may be used directly, without trivial mapping
of a 'coder-friendly' parameter name into more user-friendly text.)
Some parameters - notably those passed to Template.jsp - are not
processed at all by the Controller, but are used directly in JSPs
instead. Such parameters do not undergo
hard validation by the
ApplicationFirewall
, and are not represented by this class.
See Pattern
for more information on regular expressions.
Method Summary | |
---|---|
boolean |
equals(Object aThat)
|
static RequestParameter |
forFileUpload(String aName)
Constructor for a file upload request parameter. |
String |
getName()
Return the request parameter name. |
Pattern |
getRegex()
Return the regular expression associated with this RequestParameter. |
int |
hashCode()
|
boolean |
isFileUploadParameter()
Return true only if forFileUpload(java.lang.String) was used to build this object. |
boolean |
isValidParamValue(String aRawParamValue)
Return true only if aRawParamValue satisfies the regular expression getRegex() , or if this is a file upload
request parameter. |
String |
toString()
Intended for debugging only. |
static RequestParameter |
withLengthCheck(String aName)
Return a regular parameter hard-validated only for name and size. |
static RequestParameter |
withRegexCheck(String aName,
Pattern aValueRegex)
Return a regular parameter hard-validated for name and for value matching a regular expression. |
static RequestParameter |
withRegexCheck(String aName,
String aValueRegex)
Return a regular parameter hard-validated for name and for value matching a regular expression. |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static RequestParameter withLengthCheck(String aName)
The size is taken from the MaxRequestParamValueSize setting in web.xml.
aName
- name of the underlying HTTP request parameter. See
naming convention.public static RequestParameter withRegexCheck(String aName, Pattern aValueRegex)
aName
- name of the underlying HTTP request parameter. See
naming convention.aValueRegex
- regular expression for doing hard validation of the request
parameter value(s).public static RequestParameter withRegexCheck(String aName, String aValueRegex)
aName
- name of the underlying HTTP request parameter. See
naming convention.aValueRegex
- regular expression for doing hard validation of the request
parameter value(s).public static RequestParameter forFileUpload(String aName)
aName
- name of the underlying HTTP request parameter. See
naming convention.public String getName()
public Pattern getRegex()
This regular expression is used to perform hard validation of this parameter's value(s).
This method will return null only for file upload parameters.
public boolean isFileUploadParameter()
forFileUpload(java.lang.String)
was used to build this object.
public boolean isValidParamValue(String aRawParamValue)
getRegex()
, or if this is a file upload
request parameter.
Always represents a hard validation, not a soft validation.
public boolean equals(Object aThat)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |