# Class UrlEncodedParser (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.UrlEncodedParser)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.http.UrlEncodedParser)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.UrlEncodedParser)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.UrlEncodedParser)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.UrlEncodedParser)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.UrlEncodedParser)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.UrlEncodedParser)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.UrlEncodedParser)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.UrlEncodedParser)

    public class UrlEncodedParser implements ObjectParser

Implements support for HTTP form content encoding parsing of type `
application/x-www-form-urlencoded` as specified in the [HTML 4.0
Specification](http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#h-17.13.4.1).

Implementation is thread-safe.

The data is parsed using [#parse(String, Object)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.UrlEncodedParser#com_google_api_client_http_UrlEncodedParser_parse_java_lang_String_java_lang_Object_).

Sample usage:

static void setParser(HttpTransport transport) {
transport.addParser(new UrlEncodedParser());
}

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> UrlEncodedParser

## Implements

[ObjectParser](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.ObjectParser)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### CONTENT_TYPE

    public static final String CONTENT_TYPE

`"application/x-www-form-urlencoded"` content type.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### MEDIA_TYPE

    public static final String MEDIA_TYPE

`"application/x-www-form-urlencoded"` media type with UTF-8 encoding.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### parse(Reader reader, Object data)

    public static void parse(Reader reader, Object data)

Parses the given URL-encoded content into the given data object of data key name/value pairs,
including support for repeating data key names.

Declared fields of a "primitive" type (as defined by [Data#isPrimitive(Type)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_isPrimitive_java_lang_reflect_Type_) are
parsed using [Data#parsePrimitiveValue(Type, String)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_parsePrimitiveValue_java_lang_reflect_Type_java_lang_String_) where the [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) parameter
is the declared field class. Declared fields of type [Collection](https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html) are used to support
repeating data key names, so each member of the collection is an additional data key value.
They are parsed the same as "primitive" fields, except that the generic type parameter of the
collection is used as the [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) parameter.

If there is no declared field for an input parameter name, it will be ignored unless the
input `data` parameter is a [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html). If it is a map, the parameter value will be
stored either as a string, or as a [ArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html)\<String\> in the case of repeated
parameters.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` URL-encoded reader |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` data key name/value pairs |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### parse(Reader reader, Object data, boolean decodeEnabled)

    public static void parse(Reader reader, Object data, boolean decodeEnabled)

Parses the given URL-encoded content into the given data object of data key name/value pairs,
including support for repeating data key names.

Declared fields of a "primitive" type (as defined by [Data#isPrimitive(Type)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_isPrimitive_java_lang_reflect_Type_) are
parsed using [Data#parsePrimitiveValue(Type, String)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_parsePrimitiveValue_java_lang_reflect_Type_java_lang_String_) where the [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) parameter
is the declared field class. Declared fields of type [Collection](https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html) are used to support
repeating data key names, so each member of the collection is an additional data key value.
They are parsed the same as "primitive" fields, except that the generic type parameter of the
collection is used as the [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) parameter.

If there is no declared field for an input parameter name, it is ignored unless the input
`data` parameter is a [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html). If it is a map, the parameter value is stored either
as a string, or as a [ArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html)\<String\> in the case of repeated parameters.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` URL-encoded reader |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` data key name/value pairs |
| `decodeEnabled` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` flag that specifies whether data should be decoded. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### parse(String content, Object data)

    public static void parse(String content, Object data)

Parses the given URL-encoded content into the given data object of data key name/value pairs
using [#parse(Reader, Object)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.UrlEncodedParser#com_google_api_client_http_UrlEncodedParser_parse_java_io_Reader_java_lang_Object_).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `content` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` URL-encoded content or `null` to ignore content |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` data key name/value pairs |

### parse(String content, Object data, boolean decodeEnabled)

    public static void parse(String content, Object data, boolean decodeEnabled)

Parses the given URL-encoded content into the given data object of data key name/value pairs
using [#parse(Reader, Object)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.UrlEncodedParser#com_google_api_client_http_UrlEncodedParser_parse_java_io_Reader_java_lang_Object_).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `content` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` URL-encoded content or `null` to ignore content |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` data key name/value pairs |
| `decodeEnabled` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` flag that specifies whether decoding should be enabled. |

## Constructors

### UrlEncodedParser()

    public UrlEncodedParser()

## Methods

### \<T\>parseAndClose(InputStream in, Charset charset, Class\<T\> dataClass)

    public T <T>parseAndClose(InputStream in, Charset charset, Class<T> dataClass)

Parses the given input stream into a new instance of the the given data class of key/value
pairs and closes the input stream.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `in` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |
| `charset` | `https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html` |
| `dataClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### \<T\>parseAndClose(Reader reader, Class\<T\> dataClass)

    public T <T>parseAndClose(Reader reader, Class<T> dataClass)

Parses the given reader into a new instance of the the given data class of key/value pairs and
closes the reader.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` |
| `dataClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### parseAndClose(InputStream in, Charset charset, Type dataType)

    public Object parseAndClose(InputStream in, Charset charset, Type dataType)

Parses the given input stream into a new instance of the the given data type of key/value pairs
and closes the input stream.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `in` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |
| `charset` | `https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html` |
| `dataType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### parseAndClose(Reader reader, Type dataType)

    public Object parseAndClose(Reader reader, Type dataType)

Parses the given reader into a new instance of the the given data type of key/value pairs and
closes the reader.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` |
| `dataType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |