Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.http.client.utils
Class URLEncodedUtils

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

    @Immutable
    public class URLEncodedUtils

extends Object

A collection of utilities for encoding URLs.

Since:
  4.0

Field Summary
`static String` | `CONTENT_TYPE`

Constructor Summary
`URLEncodedUtils()`

Method Summary
`static String` | `format(Iterable<? extends NameValuePair> parameters, 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 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 void` | `parse(List<NameValuePair> parameters, Scanner scanner, String charset)` Adds all parameters within the Scanner to the list of `parameters`, as encoded by `encoding`.
`static List<NameValuePair>` | `parse(String s, Charset charset)` Returns a list of `NameValuePairs` as parsed from the given string using the given character encoding.
`static List<NameValuePair>` | `parse(URI uri, String encoding)` Returns a list of `NameValuePairs` as built from the URI's query portion.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONTENT_TYPE

    public static final String CONTENT_TYPE

See Also:
  Constant Field Values

Constructor Detail

### URLEncodedUtils

    public URLEncodedUtils()

Method Detail

### parse

    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

### parse

    public static List<NameValuePair> parse(HttpEntity entity)
                                     throws IOException

  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.

### isEncoded

    public static boolean isEncoded(HttpEntity entity)

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

### parse

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

  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.
    `charset` - Encoding to use when decoding the parameters.

### parse

    public static List<NameValuePair> parse(String s,
                                            Charset charset)

  Returns a list of `NameValuePairs` as parsed from the given string using the given character encoding.

  Parameters:
    `s` - text to parse.
    `charset` - Encoding to use when decoding the parameters.
  Since:
    4.2

### format

    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.

### format

    public static String format(Iterable<? extends NameValuePair> parameters,
                                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.

  Parameters:
    `parameters` - The parameters to include.
    `charset` - The encoding to use.
  Since:
    4.2

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2013 The Apache Software Foundation. All Rights Reserved.