Android

org.apache.http.client.utils.URLEncodedUtils

java.lang.Object
org.apache.http.client.utils.URLEncodedUtils

A collection of utilities for encoding URLs.

Summary

Constants

      Value  
String  CONTENT_TYPE    "application/x-www-form-urlencoded" 

Public Constructors

            URLEncodedUtils()

Public Methods

      static    String  format(List<? extends NameValuePair> parameters, String encoding)
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    List<NameValuePair parse(HttpEntity entity)
Returns a list of NameValuePairs as parsed from an HttpEntity.
      static    List<NameValuePair parse(URI uri, String encoding)
Returns a list of NameValuePairs as built from the URI's query portion.
      static    void  parse(List<NameValuePair> parameters, Scanner scanner, String encoding)
Adds all parameters within the Scanner to the list of parameters, as encoded by encoding.
Methods inherited from class java.lang.Object

Details

Constants

public static final String CONTENT_TYPE

Constant Value: "application/x-www-form-urlencoded"

Public Constructors

public URLEncodedUtils()

Public Methods

public static String format(List<? extends NameValuePair> parameters, String encoding)

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.

Parameters

parameters The parameters to include.
encoding The encoding to use.

public static boolean isEncoded(HttpEntity entity)

Returns true if the entity's Content-Type header is application/x-www-form-urlencoded.

public static List<NameValuePair> parse(HttpEntity entity)

Returns a list of 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.

Parameters

entity The entity to parse

Throws

IOException If there was an exception getting the entity's data.

public static List<NameValuePair> parse(URI uri, String encoding)

Returns a list of 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.

This is typically useful while parsing an HTTP PUT.

Parameters

uri uri to parse
encoding encoding to use while parsing the query

public static void parse(List<NameValuePair> parameters, Scanner scanner, String encoding)

Adds all parameters within the Scanner to the list of 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

parameters List to add parameters to.
scanner Input that contains the parameters to parse.
encoding Encoding to use when decoding the parameters.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56