|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.utexas.its.eis.tools.qwicap.servlet.FormDataSet
public final class FormDataSet
Provides a complete representation of a set of web parameters (a "Form Data Set" in official
W3C nomenclature) that is independent of the HttpServletRequest
that
supplied them. Thus, this form data set may be retained between requests. Also stored is information on the
origin of the data set including the method by which it was submitted (GET, POST, etc.), and the path to
the servlet that received them.
Constructor Summary | |
---|---|
FormDataSet()
Creates an empty FormDataSet object. |
|
FormDataSet(HttpServletRequest Req)
Creates a FormDataSet object representing the data set available from the supplied
HttpServletRequest object. |
|
FormDataSet(String WWWFormURLEncodedString,
String DefaultCharSetName)
Creates a FormDataSet instance populated with the data set extracted from a string encoded in the
"application/x-www-form-urlencoded" format. |
|
FormDataSet(String Method,
String ContextPath,
String ServletPath,
byte[] ReqBytes)
Creates a FormDataSet object representing the data set contained in the supplied byte
array. |
Method Summary | |
---|---|
FormDataSet |
addControlValues(String Name,
String... Values)
Deprecated. Use addData(java.lang.String, java.lang.Object...) instead. |
FormDataSet |
addData(String Name,
Object... Values)
Adds control name/value(s) pairs to this form data set. |
void |
clear()
Removes all data from this data set. |
FormDataSet |
deleteData(String... ControlNames)
Removes from this form data set all values associated with each of the controls identified by a name in the ControlNames parameter. |
FormDataSet |
deleteData(String ControlName)
Removes from this form data set all values associated with the control named by the ControlName
parameter. |
FormControlValue[] |
get(Pattern Regex)
Returns an array of FormControlValue objects containing all of the values in this form data set that
were supplied by controls whose names matched the supplied regular expression. |
FormControlValue |
get(String ControlName)
Returns a FormControlValue object containing all of the values in this form data set that were supplied by
controls having the specified name. |
String |
getActionURL()
Returns the action URL of this data set, if available. |
String |
getCharacterSetName()
If this data set was instantiated from a String , or byte array, of input, this method
returns the name of the character set in which the input was originally represented. |
String |
getContextPath()
As stated in the HttpServletRequest.getContextPath documentation:
Returns the portion of the request URI that indicates the context of the request. |
String |
getDatum(Pattern Regex)
Returns the first value in this form data set that was supplied by a control whose names matches the supplied regular expression. |
String |
getDatum(String ControlName)
Returns the first value in this form data set that was supplied by a control having the specified name. |
String |
getMethod()
Returns the name of the HTTP mechanism used to send this form data set to the server: "GET" or "POST". |
Exception |
getProcessingException()
Returns the Exception , if any, that was produced when this object's constructor retrieved, or attempted
to retrieve, this form data set. |
String |
getServletPath()
As stated in the HttpServletRequest.getServletPath documentation:
Returns the part of this request's URL that calls the servlet. |
String |
getValue(Pattern Regex)
Deprecated. Use getDatum(Pattern) instead. |
String |
getValue(String ControlName)
Deprecated. Use getDatum(String) instead. |
boolean |
has(String ControlName)
Returns true if there is data from the named control in this data set, or false otherwise. |
boolean |
hasControlNamesMatching(Pattern Regex)
Returns true if this form data set includes vlaues from controls whose names match the supplied
regular expression. |
boolean |
hasControlNamesStartingWith(String ControlNamePrefix)
Returns true if this form data set includes values from controls whose names begin with the specified
string. |
boolean |
isEmpty()
Returns true if this form data set is empty, false otherwise. |
Iterator<FormControlValue> |
iterator()
Returns an iterator for the complete set of FormControlValue objects in this form data set. |
boolean |
notEmpty()
Returns true if this form data set contains data, false if it is empty. |
FormDataSet |
print()
A debugging method that prints to System.out all information about this form data set and its contents. |
FormDataSet |
setActionURL(String ActionURL)
Sets the action URL of this data set. |
FormDataSet |
setCharacterSetName(String NewCharSetName)
Sets the name of the character set to be used to encode the characters of this form data set. |
FormDataSet |
setData(String Name,
Object... Values)
Adds control name/value(s) pairs to this form data set. |
FormDataSet |
setMethod(String Method)
Sets the name of the HTTP mechanism to be used to send this form data set to a server: "GET" or "POST". |
String |
toString()
Returns a human-readable representation of this data set. |
byte[] |
toWWWFormURLEncodedBytes()
Returns this data set represented as a byte array in
"application/x-www-form-urlencoded"
format. |
byte[] |
toWWWFormURLEncodedBytes(String CharSet)
Returns this data set represented as a byte array in
"application/x-www-form-urlencoded"
format. |
byte[] |
toWWWFormURLEncodedBytes(String CharSet,
char URIAttributeSeparator)
Returns this data set represented as a byte array in
"application/x-www-form-urlencoded"
format. |
String |
toWWWFormURLEncodedString()
Returns this data set represented as a String in
"application/x-www-form-urlencoded"
format. |
String |
toWWWFormURLEncodedString(String CharSet)
Returns this data set represented as a String in
"application/x-www-form-urlencoded"
format. |
String |
toWWWFormURLEncodedString(String CharSet,
char URIAttributeSeparator)
Returns this data set represented as a String in
"application/x-www-form-urlencoded"
format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FormDataSet()
FormDataSet
object.
public FormDataSet(String WWWFormURLEncodedString, String DefaultCharSetName)
FormDataSet
instance populated with the data set extracted from a string encoded in the
"application/x-www-form-urlencoded" format.
WWWFormURLEncodedString
- A String
in "application/x-www-form-urlencoded" format.DefaultCharSetName
- The name of the character set used to encode the characters of this data set. Note
that standards require that the characters of which the WWWFormURLEncodedString
parameter is composed must all be encoded using the "US-ASCII" character set, but
that the characters represented by those characters may be encoded using any
character set. The DefaultCharSetName
parameter identifies the latter
character set.public FormDataSet(String Method, String ContextPath, String ServletPath, byte[] ReqBytes)
FormDataSet
object representing the data set contained in the supplied byte
array.
Method
- The value returned by the HttpServletRequest.getMethod()
method of the current
request.ContextPath
- The value returned by the HttpServletRequest.getContextPath()
method of the
current request.ServletPath
- The value returned by the HttpServletRequest.getServletPath()
method of the
current request.ReqBytes
- The bytes of the current request in application/x-www-form-urlencoded
format. Can be null
.public FormDataSet(HttpServletRequest Req)
FormDataSet
object representing the data set available from the supplied
HttpServletRequest
object.
Req
- The current HttpServletRequest
object.Method Detail |
---|
public void clear()
@Deprecated public FormDataSet addControlValues(String Name, String... Values)
addData(java.lang.String, java.lang.Object...)
instead.
Name
- The name of the control.Values
- The value(s) of the control.
FormDataSet
object.public FormDataSet addData(String Name, Object... Values)
Name
- The name of the control.Values
- The value(s) of the control.
FormDataSet
object.public FormDataSet setData(String Name, Object... Values)
Name
- The name of the control.Values
- The value(s) of the control.
FormDataSet
object.public String getCharacterSetName()
String
, or byte
array, of input, this method
returns the name of the character set in which the input was originally represented. (In its encoded form, the
input is required by RFC 1738 to be in the US-ASCII character set,
but the encoded bytes could represent characters in any character set.) If this data set was instantiated
using the default constructor, a general-purpose character set (almost certainly UTF-8) will have been selected as
the default, and this method will return the name of that character set.
public FormDataSet setCharacterSetName(String NewCharSetName)
NewCharSetName
- The name of the character set used to be used to encode the characters of this form
data set.
FormDataSet
instance.public String getMethod()
public FormDataSet setMethod(String Method)
Method
- The name of the HTTP mechanism ("get" or "post") to be used to send this form data set
to a server.
FormDataSet
instance.public String getActionURL()
null
is returned. The action
URL of a data set received from an HttpServletRequest
is the URL to which the data set was sent. The
action URL of a data set extracted from an XHTML page is the URL to which the data set should be sent. If the
method used by this data set is "get" (see getMethod()
), this data set will be appropriately encoded and
appended to the URL as URI attributes, for example: "http://localhost/app/?hello=world&foo=bar".
null
.public FormDataSet setActionURL(String ActionURL)
HttpServletRequest
,
the action URL should indicate the URL to which the data set was sent (see
HttpServletRequest.getRequestURL()
). In the case of a data set extract from an XHTML page, the action URL
should specify where the data set is meant to be sent.
ActionURL
- The action URL of this data set.
FormDataSet
instance.public String getContextPath()
HttpServletRequest.getContextPath
documentation:
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.
public String getServletPath()
HttpServletRequest.getServletPath
documentation:
Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.
public Exception getProcessingException()
Exception
, if any, that was produced when this object's constructor retrieved, or attempted
to retrieve, this form data set.
Exception
produced when this form data set was built, or null
if everything
worked correctly.public boolean isEmpty()
true
if this form data set is empty, false
otherwise.
true
if this form data set is empty, false
otherwise.public boolean notEmpty()
true
if this form data set contains data, false
if it is empty.
true
if this form data set contains data, false
if it is empty.public FormControlValue get(String ControlName)
FormControlValue
object containing all of the values in this form data set that were supplied by
controls having the specified name.
ControlName
- The name of the control(s) whose value(s) should be returned.
FormControlValue
object containing all of the values supplied by controls having the
specified name, or null
if there are no such values.public FormControlValue[] get(Pattern Regex)
FormControlValue
objects containing all of the values in this form data set that
were supplied by controls whose names matched the supplied regular expression.
Regex
- The regular expression compiled as a Pattern
object.
FormControlValue
object for each value (or set of values) whose name
matched the regular expression, or an empty array if there are no such controls.@Deprecated public String getValue(String ControlName)
getDatum(String)
instead.
ControlName
- The name of the control(s) whose first value should be returned.
null
if there are no such
values.public String getDatum(String ControlName)
ControlName
- The name of the control(s) whose first value should be returned.
null
if there are no such
values.@Deprecated public String getValue(Pattern Regex)
getDatum(Pattern)
instead.
Regex
- The regular expression compiled as a Pattern
object.
null
if there are no such
values.public String getDatum(Pattern Regex)
Regex
- The regular expression compiled as a Pattern
object.
null
if there are no such
values.public boolean has(String ControlName)
true
if there is data from the named control in this data set, or false
otherwise.
ControlName
- Control name.
true
if there is data from the named control in this data set, or
false
otherwise.public boolean hasControlNamesStartingWith(String ControlNamePrefix)
true
if this form data set includes values from controls whose names begin with the specified
string. The substring comparison is case-sensitive.
ControlNamePrefix
- Control name prefix for which to test.
true
if this form data set includes values from controls whose names begin
with the specified string, false
otherwise.public boolean hasControlNamesMatching(Pattern Regex)
true
if this form data set includes vlaues from controls whose names match the supplied
regular expression.
Regex
- The regular expression compiled as a Pattern
object.
true
if this form data set includes values from controls whose names
are matched by the specified regular expression, false
otherwise.public FormDataSet deleteData(String ControlName)
ControlName
parameter. If there is no such control in the data set, nothing happens.
ControlName
- The name of the control whose values should be removed from this form data set.
FormDataSet
instance, in order to enable method
invocation chaining.public FormDataSet deleteData(String... ControlNames)
ControlNames
parameter. When there is no control corresponding to a specified name, nothing happens.
ControlNames
- The names of the controls whose values should be removed from this form data set.
FormDataSet
instance, in order to enable method
invocation chaining.public Iterator<FormControlValue> iterator()
FormControlValue
objects in this form data set. Don't be
surprised to find more than just the values from your own form controls, because the full-up Qwicap system (as
opposed to the templater) adds hidden "input" controls to all forms for its internal use. Their names are always
prefixed with "qwicap" to avoid name collisions. You can use the FormControlValue.isQwicapControl
method to conveniently identify the control values that Qwicap has added.
iterator
in interface Iterable<FormControlValue>
FormControlValue
objects in this form data set.public String toString()
toString
in class Object
public String toWWWFormURLEncodedString()
String
in
"application/x-www-form-urlencoded"
format. Like any String
in Java, the characters comprising this string are Unicode, but, as required by
RFC 1738 all of the Unicode characters used in this string
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2). Thus, while this string is not actually in the
required US-ASCII character set (it's in UTF-16, like all Java String
objects), it is guaranteed to be
perfectly convertable to US-ASCII, in keeping with all of the requirements of RFC 1738.
The characters comprising the actual names and values of the data in this data set
are encoded in the original/default character set for this data set (see getCharacterSetName()
). The
bytes produced by that encoding are the bytes that are subsequently encoded in the "application/x-www-form-urlencoded"
format using only the prescribed portions of the US-ASCII character set as specified by RFC 1738. Thus, the data of
this data set may be encoded in any character set, but still be represented entirely by US-ASCII characters, as
required.
String
representation of this data set in the "application/x-www-form-urlencoded"
format.public String toWWWFormURLEncodedString(String CharSet)
String
in
"application/x-www-form-urlencoded"
format. Like any String
in Java, the characters comprising this string are Unicode, but, as required by
RFC 1738 all of the Unicode characters used in this string
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2). Thus, while this string is not actually in the
required US-ASCII character set (it's in UTF-16, like all Java String
objects), it is guaranteed to be
perfectly convertable to US-ASCII, in keeping with all of the requirements of RFC 1738.
The characters comprising the actual names and values of the data in this data set are encoded in the character
set specified by the CharSet
parameter. The bytes produced by that encoding are the bytes that are
subsequently encoded in the "application/x-www-form-urlencoded" format using only the prescribed portions of the
US-ASCII character set as specified by RFC 1738. Thus, the data of this data set may be encoded in any character
set, but still be represented entirely by US-ASCII characters, as required.
CharSet
- The name of the character set in which the names and values of the data in this data set are to
be encoded.
String
representation of this data set in the "application/x-www-form-urlencoded"
format.public String toWWWFormURLEncodedString(String CharSet, char URIAttributeSeparator)
String
in
"application/x-www-form-urlencoded"
format. Like any String
in Java, the characters comprising this string are Unicode, but, as required by
RFC 1738 all of the Unicode characters used in this string
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2). Thus, while this string is not actually in the
required US-ASCII character set (it's in UTF-16, like all Java String
objects), it is guaranteed to be
perfectly convertable to US-ASCII, in keeping with all of the requirements of RFC 1738.
The characters comprising the actual names and values of the data in this data set are encoded in the character
set specified by the CharSet
parameter. The bytes produced by that encoding are the bytes that are
subsequently encoded in the "application/x-www-form-urlencoded" format using only the prescribed portions of the
US-ASCII character set as specified by RFC 1738. Thus, the data of this data set may be encoded in any character
set, but still be represented entirely by US-ASCII characters, as required.
When a data set is encoded in "application/x-www-form-urlencoded" format for use in an HTTP URL, the name/value
pairs of the data set may be separated by either ampersand ('&'), or semicolon (';'), characters. (See
HTML 4 Specification, Section B.2.2,
"Ampersands in URI Attribute Values".) The ampersand is the most common separator, but the semicolon is the
most covenient when the string is to be placed into HTML markup, because a semicolon does not have to be encoded as
an HTML character entity reference, unlike an ampersand
(which ends-up as either "&", or ";"). The URIAttributeSeparator
parameter allows you
to specify whether an ampersand or a semicolon should be used.
CharSet
- The name of the character set in which the names and values of the data in this
data set are to be encoded.URIAttributeSeparator
- Either an ampersand ('&'), or a semicolon (';'), character.
String
representation of this data set in the
"application/x-www-form-urlencoded" format.public byte[] toWWWFormURLEncodedBytes()
byte
array in
"application/x-www-form-urlencoded"
format. As required by RFC 1738, all bytes in the array
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2).
The characters comprising the actual names and values of the data in this data set
are encoded in the original/default character set for this data set (see getCharacterSetName()
). The
bytes produced by that encoding are the bytes that are subsequently encoded in the "application/x-www-form-urlencoded"
format using only the prescribed portions of the US-ASCII character set as specified by RFC 1738. Thus, the data of
this data set may be encoded in any character set, but still be represented entirely by US-ASCII character codes,
as required.
byte
array representing this data set in the "application/x-www-form-urlencoded"
format.public byte[] toWWWFormURLEncodedBytes(String CharSet)
byte
array in
"application/x-www-form-urlencoded"
format. As required by RFC 1738, all bytes in the array
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2).
The characters comprising the actual names and values of the data in this data set are encoded in the character
set specified by the CharSet
parameter. The bytes produced by that encoding are the bytes that are
subsequently encoded in the "application/x-www-form-urlencoded" format using only the prescribed portions of the
US-ASCII character set as specified by RFC 1738. Thus, the data of this data set may be encoded in any character
set, but still be represented entirely by US-ASCII character codes, as required.
CharSet
- The name of the character set in which the names and values of the data in this data set are to
be encoded.
byte
array representing this data set in the "application/x-www-form-urlencoded"
format.public byte[] toWWWFormURLEncodedBytes(String CharSet, char URIAttributeSeparator)
byte
array in
"application/x-www-form-urlencoded"
format. As required by RFC 1738, all bytes in the array
correspond directly to "the graphic printable characters of the US-ASCII coded character set", excluding those
characters that RFC 1738 labels "unsafe" (see section 2.2).
The characters comprising the actual names and values of the data in this data set are encoded in the character
set specified by the CharSet
parameter. The bytes produced by that encoding are the bytes that are
subsequently encoded in the "application/x-www-form-urlencoded" format using only the prescribed portions of the
US-ASCII character set as specified by RFC 1738. Thus, the data of this data set may be encoded in any character
set, but still be represented entirely by US-ASCII character codes, as required.
When a data set is encoded in "application/x-www-form-urlencoded" format for use in an HTTP URL, the name/value
pairs of the data set may be separated by either ampersand ('&'), or semicolon (';'), characters. (See
HTML 4 Specification, Section B.2.2,
"Ampersands in URI Attribute Values".) The ampersand is the most common separator, but the semicolon is the
most covenient when the string is to be placed into HTML markup, because a semicolon does not have to be encoded as
an HTML character entity reference, unlike an ampersand
(which ends-up as either "&", or ";"). The URIAttributeSeparator
parameter allows you
to specify whether an ampersand or a semicolon should be used.
CharSet
- The name of the character set in which the names and values of the data in this
data set are to be encoded.URIAttributeSeparator
- Either an ampersand ('&'), or a semicolon (';'), character.
byte
array representing this data set in the
"application/x-www-form-urlencoded" format.public FormDataSet print()
System.out
all information about this form data set and its contents.
Note that, in general, the best way to see this information is not by modifying your code to invoke this
print
method, but by setting the logging level for this class to FINE
.
FormDataSet
instance.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |