public class QueryStringDecoder
extends java.lang.Object
This decoder can also decode the content of an HTTP POST request whose content type is application/x-www-form-urlencoded:QueryStringDecoder
decoder = newQueryStringDecoder
("/hello?recipient=world&x=1;y=2"); assert decoder.path().equals("/hello"); assert decoder.parameters().get("recipient").get(0).equals("world"); assert decoder.parameters().get("x").get(0).equals("1"); assert decoder.parameters().get("y").get(0).equals("2");
QueryStringDecoder
decoder = newQueryStringDecoder
("recipient=world&x=1;y=2", false); ...
QueryStringEncoder
构造器和说明 |
---|
QueryStringDecoder(java.lang.String uri)
Creates a new decoder that decodes the specified URI.
|
QueryStringDecoder(java.lang.String uri,
boolean hasPath)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.lang.String uri,
java.nio.charset.Charset charset)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.lang.String uri,
java.nio.charset.Charset charset,
boolean hasPath)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.lang.String uri,
java.nio.charset.Charset charset,
boolean hasPath,
int maxParams)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.lang.String uri,
java.nio.charset.Charset charset,
boolean hasPath,
int maxParams,
boolean semicolonIsNormalChar)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.net.URI uri)
Creates a new decoder that decodes the specified URI.
|
QueryStringDecoder(java.net.URI uri,
java.nio.charset.Charset charset)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.net.URI uri,
java.nio.charset.Charset charset,
int maxParams)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
QueryStringDecoder(java.net.URI uri,
java.nio.charset.Charset charset,
int maxParams,
boolean semicolonIsNormalChar)
Creates a new decoder that decodes the specified URI encoded in the
specified charset.
|
限定符和类型 | 方法和说明 |
---|---|
static java.lang.String |
decodeComponent(java.lang.String s)
Decodes a bit of a URL encoded by a browser.
|
static java.lang.String |
decodeComponent(java.lang.String s,
java.nio.charset.Charset charset)
Decodes a bit of a URL encoded by a browser.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
parameters()
Returns the decoded key-value parameter pairs of the URI.
|
java.lang.String |
path()
Returns the decoded path string of the URI.
|
java.lang.String |
rawPath()
Returns the raw path string of the URI.
|
java.lang.String |
rawQuery()
Returns raw query string of the URI.
|
java.lang.String |
toString() |
java.lang.String |
uri()
Returns the uri used to initialize this
QueryStringDecoder . |
public QueryStringDecoder(java.lang.String uri)
public QueryStringDecoder(java.lang.String uri, boolean hasPath)
public QueryStringDecoder(java.lang.String uri, java.nio.charset.Charset charset)
public QueryStringDecoder(java.lang.String uri, java.nio.charset.Charset charset, boolean hasPath)
public QueryStringDecoder(java.lang.String uri, java.nio.charset.Charset charset, boolean hasPath, int maxParams)
public QueryStringDecoder(java.lang.String uri, java.nio.charset.Charset charset, boolean hasPath, int maxParams, boolean semicolonIsNormalChar)
public QueryStringDecoder(java.net.URI uri)
public QueryStringDecoder(java.net.URI uri, java.nio.charset.Charset charset)
public QueryStringDecoder(java.net.URI uri, java.nio.charset.Charset charset, int maxParams)
public QueryStringDecoder(java.net.URI uri, java.nio.charset.Charset charset, int maxParams, boolean semicolonIsNormalChar)
public java.lang.String toString()
toString
在类中 java.lang.Object
public java.lang.String uri()
QueryStringDecoder
.public java.lang.String path()
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters()
public java.lang.String rawPath()
public java.lang.String rawQuery()
public static java.lang.String decodeComponent(java.lang.String s)
This is equivalent to calling decodeComponent(String, Charset)
with the UTF-8 charset (recommended to comply with RFC 3986, Section 2).
s
- The string to decode (can be empty).s
if there's nothing to decode.
If the string to decode is null
, returns an empty string.java.lang.IllegalArgumentException
- if the string contains a malformed
escape sequence.public static java.lang.String decodeComponent(java.lang.String s, java.nio.charset.Charset charset)
The string is expected to be encoded as per RFC 3986, Section 2.
This is the encoding used by JavaScript functions encodeURI
and encodeURIComponent
, but not escape
. For example
in this encoding, é (in Unicode U+00E9
or in UTF-8
0xC3 0xA9
) is encoded as %C3%A9
or %c3%a9
.
This is essentially equivalent to calling
URLDecoder.decode(String, String)
except that it's over 2x faster and generates less garbage for the GC.
Actually this function doesn't allocate any memory if there's nothing
to decode, the argument itself is returned.
s
- The string to decode (can be empty).charset
- The charset to use to decode the string (should really
be CharsetUtil.UTF_8
.s
if there's nothing to decode.
If the string to decode is null
, returns an empty string.java.lang.IllegalArgumentException
- if the string contains a malformed
escape sequence.