@Immutable public class URLEncodedUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTENT_TYPE
The default HTML form content type.
|
Constructor and Description |
---|
URLEncodedUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static java.lang.String |
encPath(java.lang.String content,
java.nio.charset.Charset charset)
Encode a String using the
PATHSAFE set of characters. |
(package private) static java.lang.String |
encUric(java.lang.String content,
java.nio.charset.Charset charset)
Encode a String using the
URIC set of characters. |
(package private) static java.lang.String |
encUserInfo(java.lang.String content,
java.nio.charset.Charset charset)
Encode a String using the
USERINFO set of characters. |
static java.lang.String |
format(java.lang.Iterable<? extends NameValuePair> parameters,
char parameterSeparator,
java.nio.charset.Charset charset)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST. |
static java.lang.String |
format(java.lang.Iterable<? extends NameValuePair> parameters,
java.nio.charset.Charset charset)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST. |
static java.lang.String |
format(java.util.List<? extends NameValuePair> parameters,
char parameterSeparator,
java.lang.String charset)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST. |
static java.lang.String |
format(java.util.List<? extends NameValuePair> parameters,
java.lang.String charset)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST. |
static boolean |
isEncoded(HttpEntity entity)
Returns true if the entity's Content-Type header is
application/x-www-form-urlencoded . |
static java.util.List<NameValuePair> |
parse(CharArrayBuffer buf,
java.nio.charset.Charset charset,
char... separators)
Returns a list of
NameValuePairs as parsed from the given string using
the given character encoding. |
static java.util.List<NameValuePair> |
parse(HttpEntity entity)
Returns a list of
NameValuePairs as parsed from an HttpEntity . |
static void |
parse(java.util.List<NameValuePair> parameters,
java.util.Scanner scanner,
java.lang.String charset)
Deprecated.
(4.4) use
parse(String, java.nio.charset.Charset) |
static void |
parse(java.util.List<NameValuePair> parameters,
java.util.Scanner scanner,
java.lang.String parameterSepartorPattern,
java.lang.String charset)
Deprecated.
|
static java.util.List<NameValuePair> |
parse(java.lang.String s,
java.nio.charset.Charset charset)
Returns a list of
NameValuePairs as parsed from the given string using the given character
encoding. |
static java.util.List<NameValuePair> |
parse(java.lang.String s,
java.nio.charset.Charset charset,
char... separators)
Returns a list of
NameValuePairs as parsed from the given string using the given character
encoding. |
static java.util.List<NameValuePair> |
parse(java.net.URI uri,
java.lang.String charset)
Returns a list of
NameValuePairs as built from the URI's query portion. |
public static final java.lang.String CONTENT_TYPE
public static java.util.List<NameValuePair> parse(java.net.URI uri, java.lang.String charset)
NameValuePairs
as built from the URI's query portion. For example, a URI
of http://example.org/path/to/file?a=1&b=2&c=3
would return a list of three NameValuePairs, one for a=1,
one for b=2, and one for c=3. By convention, '&'
and ';'
are accepted as parameter separators.
This is typically useful while parsing an HTTP PUT. This API is currently only used for testing.
uri
- URI to parsecharset
- Charset name to use while parsing the queryNameValuePair
as built from the URI's query portion.public static java.util.List<NameValuePair> parse(HttpEntity entity) throws java.io.IOException
NameValuePairs
as parsed from an HttpEntity
.
The encoding is taken from the entity's Content-Encoding header.
This is typically used while parsing an HTTP POST.
entity
- The entity to parseNameValuePair
as built from the URI's query portion.java.io.IOException
- If there was an exception getting the entity's data.public static boolean isEncoded(HttpEntity entity)
application/x-www-form-urlencoded
.@Deprecated public static void parse(java.util.List<NameValuePair> parameters, java.util.Scanner scanner, java.lang.String charset)
parse(String, java.nio.charset.Charset)
parameters
, as encoded by
encoding
. For example, a scanner containing the string a=1&b=2&c=3
would add the
NameValuePairs
a=1, b=2, and c=3 to the list of parameters. By convention, '&'
and
';'
are accepted as parameter separators.parameters
- List to add parameters to.scanner
- Input that contains the parameters to parse.charset
- Encoding to use when decoding the parameters.@Deprecated public static void parse(java.util.List<NameValuePair> parameters, java.util.Scanner scanner, java.lang.String parameterSepartorPattern, java.lang.String charset)
parse(org.apache.http.util.CharArrayBuffer, java.nio.charset.Charset, char...)
parameters
, as encoded by encoding
. For
example, a scanner containing the string a=1&b=2&c=3
would
add the NameValuePairs
a=1, b=2, and c=3 to the
list of parameters.parameters
- List to add parameters to.scanner
- Input that contains the parameters to parse.parameterSepartorPattern
- The Pattern string for parameter separators, by convention "[&;]"
charset
- Encoding to use when decoding the parameters.public static java.util.List<NameValuePair> parse(java.lang.String s, java.nio.charset.Charset charset)
NameValuePairs
as parsed from the given string using the given character
encoding. By convention, '&'
and ';'
are accepted as parameter separators.s
- text to parse.charset
- Encoding to use when decoding the parameters.NameValuePair
as built from the URI's query portion.public static java.util.List<NameValuePair> parse(java.lang.String s, java.nio.charset.Charset charset, char... separators)
NameValuePairs
as parsed from the given string using the given character
encoding.s
- text to parse.charset
- Encoding to use when decoding the parameters.separators
- element separators.NameValuePair
as built from the URI's query portion.public static java.util.List<NameValuePair> parse(CharArrayBuffer buf, java.nio.charset.Charset charset, char... separators)
NameValuePairs
as parsed from the given string using
the given character encoding.buf
- text to parse.charset
- Encoding to use when decoding the parameters.separators
- element separators.NameValuePair
as built from the URI's query portion.public static java.lang.String format(java.util.List<? extends NameValuePair> parameters, java.lang.String charset)
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST.parameters
- The parameters to include.charset
- The encoding to use.application/x-www-form-urlencoded
stringpublic static java.lang.String format(java.util.List<? extends NameValuePair> parameters, char parameterSeparator, java.lang.String charset)
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST.parameters
- The parameters to include.parameterSeparator
- The parameter separator, by convention, '&'
or ';'
.charset
- The encoding to use.application/x-www-form-urlencoded
stringpublic static java.lang.String format(java.lang.Iterable<? extends NameValuePair> parameters, java.nio.charset.Charset charset)
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST.parameters
- The parameters to include.charset
- The encoding to use.application/x-www-form-urlencoded
stringpublic static java.lang.String format(java.lang.Iterable<? extends NameValuePair> parameters, char parameterSeparator, java.nio.charset.Charset charset)
application/x-www-form-urlencoded
list of parameters in an HTTP PUT or HTTP POST.parameters
- The parameters to include.parameterSeparator
- The parameter separator, by convention, '&'
or ';'
.charset
- The encoding to use.application/x-www-form-urlencoded
stringstatic java.lang.String encUserInfo(java.lang.String content, java.nio.charset.Charset charset)
USERINFO
set of characters.
Used by URIBuilder to encode the userinfo segment.
content
- the string to encode, does not convert space to '+'charset
- the charset to usestatic java.lang.String encUric(java.lang.String content, java.nio.charset.Charset charset)
URIC
set of characters.
Used by URIBuilder to encode the query and fragment segments.
content
- the string to encode, does not convert space to '+'charset
- the charset to usestatic java.lang.String encPath(java.lang.String content, java.nio.charset.Charset charset)
PATHSAFE
set of characters.
Used by URIBuilder to encode path segments.
content
- the string to encode, does not convert space to '+'charset
- the charset to use