Package org.apache.http.client.utils
Class URLEncodedUtils
java.lang.Object
org.apache.http.client.utils.URLEncodedUtils
A collection of utilities for encoding URLs.
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(Iterable<? extends NameValuePair> parameters, char parameterSeparator, Charset charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.static Stringformat(Iterable<? extends NameValuePair> parameters, Charset charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.static Stringformat(List<? extends NameValuePair> parameters, char parameterSeparator, String charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.static Stringformat(List<? extends NameValuePair> parameters, String charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.static StringformatSegments(Iterable<String> segments, Charset charset) Returns a string consisting of joint encoded path segments.static StringformatSegments(String... segments) Returns a string consisting of joint encoded path segments.static booleanisEncoded(HttpEntity entity) Returns true if the entity's Content-Type header isapplication/x-www-form-urlencoded.static List<NameValuePair> Returns a list ofNameValuePairs URI query parameters.static List<NameValuePair> Returns a list ofNameValuePairsas parsed from the given string using the given character encoding.static List<NameValuePair> Deprecated.static List<NameValuePair> Returns a list ofNameValuePairs URI query parameters.static voidparse(List<NameValuePair> parameters, Scanner scanner, String charset) Deprecated.(4.4) useparse(String, java.nio.charset.Charset)static voidparse(List<NameValuePair> parameters, Scanner scanner, String parameterSepartorPattern, String charset) Deprecated.static List<NameValuePair> parse(HttpEntity entity) Returns a list ofNameValuePairsas parsed from anHttpEntity.static List<NameValuePair> parse(CharArrayBuffer buf, Charset charset, char... separators) Returns a list ofNameValuePairs parameters.Returns a list of URI path segments.parsePathSegments(CharSequence s, Charset charset) Returns a list of URI path segments.
-
Field Details
-
CONTENT_TYPE
The default HTML form content type.- See Also:
-
-
Constructor Details
-
URLEncodedUtils
public URLEncodedUtils()
-
-
Method Details
-
parse
Deprecated.4.5 Useparse(URI, Charset) -
parse
Returns a list ofNameValuePairs URI query parameters. By convention,'&'and';'are accepted as parameter separators.- Parameters:
uri- input URI.charset- parameter charset.- Returns:
- list of query parameters.
- Since:
- 4.5
-
parse
Returns a list ofNameValuePairsas parsed from anHttpEntity. The encoding is taken from the entity's Content-Encoding header.This is typically used while parsing an HTTP POST.
- Parameters:
entity- The entity to parse- Returns:
- a list of
NameValuePairas built from the URI's query portion. - Throws:
IOException- If there was an exception getting the entity's data.
-
isEncoded
Returns true if the entity's Content-Type header isapplication/x-www-form-urlencoded. -
parse
@Deprecated public static void parse(List<NameValuePair> parameters, Scanner scanner, String charset) Deprecated.(4.4) useparse(String, java.nio.charset.Charset)Adds all parameters within the Scanner to the list ofparameters, as encoded byencoding. For example, a scanner containing the stringa=1&b=2&c=3would add theNameValuePairsa=1, b=2, and c=3 to the list of parameters. By convention,'&'and';'are accepted as parameter separators.- Parameters:
parameters- List to add parameters to.scanner- Input that contains the parameters to parse.charset- Encoding to use when decoding the parameters.
-
parse
@Deprecated public static void parse(List<NameValuePair> parameters, Scanner scanner, String parameterSepartorPattern, String charset) Deprecated.Adds all parameters within the Scanner to the list ofparameters, as encoded byencoding. For example, a scanner containing the stringa=1&b=2&c=3would add theNameValuePairsa=1, b=2, and c=3 to the list of parameters.- 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.
-
parse
Returns a list ofNameValuePairs URI query parameters. By convention,'&'and';'are accepted as parameter separators.- Parameters:
s- URI query component.charset- charset to use when decoding the parameters.- Returns:
- list of query parameters.
- Since:
- 4.2
-
parse
Returns a list ofNameValuePairsas parsed from the given string using the given character encoding.- Parameters:
s- input text.charset- parameter charset.separators- parameter separators.- Returns:
- list of query parameters.
- Since:
- 4.3
-
parse
Returns a list ofNameValuePairs parameters.- Parameters:
buf- text to parse.charset- Encoding to use when decoding the parameters.separators- element separators.- Returns:
- a list of
NameValuePairas built from the URI's query portion. - Since:
- 4.4
-
parsePathSegments
Returns a list of URI path segments.- Parameters:
s- URI path component.charset- parameter charset.- Returns:
- list of segments.
- Since:
- 4.5
-
parsePathSegments
Returns a list of URI path segments.- Parameters:
s- URI path component.- Returns:
- list of segments.
- Since:
- 4.5
-
formatSegments
Returns a string consisting of joint encoded path segments.- Parameters:
segments- the segments.charset- parameter charset.- Returns:
- URI path component
- Since:
- 4.5
-
formatSegments
Returns a string consisting of joint encoded path segments.- Parameters:
segments- the segments.- Returns:
- URI path component
- Since:
- 4.5
-
format
Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.- Parameters:
parameters- The parameters to include.charset- The encoding to use.- Returns:
- An
application/x-www-form-urlencodedstring
-
format
public static String format(List<? extends NameValuePair> parameters, char parameterSeparator, String charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.- Parameters:
parameters- The parameters to include.parameterSeparator- The parameter separator, by convention,'&'or';'.charset- The encoding to use.- Returns:
- An
application/x-www-form-urlencodedstring - Since:
- 4.3
-
format
Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.- Parameters:
parameters- The parameters to include.charset- The encoding to use.- Returns:
- An
application/x-www-form-urlencodedstring - Since:
- 4.2
-
format
public static String format(Iterable<? extends NameValuePair> parameters, char parameterSeparator, Charset charset) Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.- Parameters:
parameters- The parameters to include.parameterSeparator- The parameter separator, by convention,'&'or';'.charset- The encoding to use.- Returns:
- An
application/x-www-form-urlencodedstring - Since:
- 4.3
-
parse(URI, Charset)