public class QueryParser extends MapParser<String> implements Query
ParameterParser
is used to parse data encoded in
the application/x-www-form-urlencoded
MIME type. It
is also used to parse a query string from a HTTP URL, see RFC 2616.
The parsed parameters are available through the various methods of
the org.simpleframework.http.net.Query
interface. The
syntax of the parsed parameters is described below in BNF.
params = *(pair [ "&" params]) pair = name "=" value name = *(text | escaped) value = *(text | escaped) escaped = % HEX HEXThis will consume all data found as a name or value, if the data is a "+" character then it is replaced with a space character. This regards only "=", "&", and "%" as having special values. The "=" character delimits the name from the value and the "&" delimits the name value pair. The "%" character represents the start of an escaped sequence, which consists of two hex digits. All escaped sequences are converted to its character value.
Constructor and Description |
---|
QueryParser()
Constructor for the
ParameterParser . |
QueryParser(String text)
Constructor for the
ParameterParser . |
Modifier and Type | Method and Description |
---|---|
boolean |
getBoolean(Object name)
This extracts a boolean parameter for the named value.
|
float |
getFloat(Object name)
This extracts a float parameter for the named value.
|
int |
getInteger(Object name)
This extracts an integer parameter for the named value.
|
protected void |
init()
This initializes the parser so that it can be used several
times.
|
protected void |
parse()
This performs the actual parsing of the parameter text.
|
String |
toString()
This
toString method is used to compose an string
in the application/x-www-form-urlencoded MIME type. |
String |
toString(Set set)
This
toString method is used to compose an string
in the application/x-www-form-urlencoded MIME type. |
clear, containsKey, containsValue, entrySet, get, getAll, isEmpty, keySet, put, putAll, remove, size, values
digit, ensureCapacity, parse, skip, space, toLower
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public QueryParser()
ParameterParser
. This creates
an instance that can be use to parse HTML form data and URL
query strings encoded as application/x-www-form-urlencoded.
The parsed parameters are made available through the interface
org.simpleframework.util.net.Query
.public QueryParser(String text)
ParameterParser
. This creates
an instance that can be use to parse HTML form data and URL
query strings encoded as application/x-www-form-urlencoded.
The parsed parameters are made available through the interface
org.simpleframework.util.net.Query
.text
- this is the text to parse for the parameterspublic int getInteger(Object name)
getInteger
in interface Query
name
- the name of the parameter value to retrievepublic float getFloat(Object name)
public boolean getBoolean(Object name)
true
or
false
then those boolean values are returned.getBoolean
in interface Query
name
- the name of the parameter value to retrieveprotected void init()
parse(String)
is
invoked the status of the Query
is empty.protected void parse()
public String toString(Set set)
toString
method is used to compose an string
in the application/x-www-form-urlencoded
MIME type.
This will encode the tokens specified in the Set
.
Each name=value pair acquired is converted into a UTF-8 escape
sequence so that the parameters can be sent in the IS0-8859-1
format required via the HTTP/1.1 specification RFC 2616.set
- this is the set of parameters to be encodedpublic String toString()
toString
method is used to compose an string
in the application/x-www-form-urlencoded
MIME type.
This will iterate over all tokens that have been added to this
object, either during parsing, or during use of the instance.
Each name=value pair acquired is converted into a UTF-8 escape
sequence so that the parameters can be sent in the IS0-8859-1
format required via the HTTP/1.1 specification RFC 2616.Copyright © 2015. All rights reserved.