Package org.apache.http.client.utils
Class URLEncodedUtils
java.lang.Object
org.apache.http.client.utils.URLEncodedUtils
public class URLEncodedUtils extends Object
A collection of utilities for encoding URLs.
-
Field Summary
Fields Modifier and Type Field Description static StringCONTENT_TYPE -
Constructor Summary
Constructors Constructor Description URLEncodedUtils() -
Method Summary
Modifier and Type Method Description static Stringformat(List<? extends NameValuePair> parameters, String encoding)Returns a String that is suitable for use as anapplication/x-www-form-urlencodedlist of parameters in an HTTP PUT or HTTP POST.static booleanisEncoded(HttpEntity entity)Returns true if the entity's Content-Type header isapplication/x-www-form-urlencoded.static List<NameValuePair>parse(URI uri, String encoding)Returns a list ofNameValuePairsas built from the URI's query portion.static voidparse(List<NameValuePair> parameters, Scanner scanner, String encoding)Adds all parameters within the Scanner to the list ofparameters, as encoded byencoding.static List<NameValuePair>parse(HttpEntity entity)Returns a list ofNameValuePairsas parsed from anHttpEntity.
-
Field Details
-
CONTENT_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
URLEncodedUtils
public URLEncodedUtils()
-
-
Method Details
-
parse
Returns a list ofNameValuePairsas 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.This is typically useful while parsing an HTTP PUT.
- Parameters:
uri- uri to parseencoding- encoding to use while parsing the query
-
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- 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
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.encoding- Encoding to use when decoding the parameters.
-
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.encoding- The encoding to use.
-