org.restlet.engine.util

## Class FormReader

- java.lang.Object
- - org.restlet.engine.util.FormReader

    public class FormReader
    extends java.lang.Object

Form reader.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`FormReader(Representation representation)` Constructor. In case the representation does not define a character set, the UTF-8 character set is used.
`FormReader(java.lang.String parametersString, char separator)` Constructor.
`FormReader(java.lang.String parametersString, CharacterSet characterSet, char separator)` Constructor.

### Method Summary

Methods
`void` `addParameters(Form form)` Adds the parameters into a given form.
`Form` `read()` Reads all the parameters.
`Parameter` `readFirstParameter(java.lang.String name)` Reads the first parameter with the given name.
`Parameter` `readNextParameter()` Reads the next parameter available or null.
`java.lang.Object` `readParameter(java.lang.String name)` Reads the parameters with the given name.
`void` `readParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)` Reads the parameters whose name is a key in the given map.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### FormReader

    public FormReader(Representation representation)
               throws java.io.IOException

Constructor.
In case the representation does not define a character set, the UTF-8 character set is used.

Parameters:
  `representation` - The web form content.
Throws:
  `java.io.IOException` - if the stream of the representation could not be opened.

#### FormReader

    public FormReader(java.lang.String parametersString,
              char separator)

Constructor. Will leave the parsed data encoded.

Parameters:
  `parametersString` - The parameters string.

#### FormReader

    public FormReader(java.lang.String parametersString,
              CharacterSet characterSet,
              char separator)

Constructor.

Parameters:
  `parametersString` - The parameters string.
  `characterSet` - The supported character encoding. Set to null to leave the data encoded.

### Method Detail

#### addParameters

    public void addParameters(Form form)

Adds the parameters into a given form.

Parameters:
  `form` - The target form.

#### read

    public Form read()
              throws java.io.IOException

Reads all the parameters.

Returns:
  The form read.
Throws:
  `java.io.IOException` - If the parameters could not be read.

#### readFirstParameter

    public Parameter readFirstParameter(java.lang.String name)
                                 throws java.io.IOException

Reads the first parameter with the given name.

Parameters:
  `name` - The parameter name to match.
Returns:
  The parameter value.
Throws:
  `java.io.IOException`

#### readNextParameter

    public Parameter readNextParameter()
                                throws java.io.IOException

Reads the next parameter available or null.

Returns:
  The next parameter available or null.
Throws:
  `java.io.IOException` - If the next parameter could not be read.

#### readParameter

    public java.lang.Object readParameter(java.lang.String name)
                                   throws java.io.IOException

Reads the parameters with the given name. If multiple values are found, a list is returned created.

Parameters:
  `name` - The parameter name to match.
Returns:
  The parameter value or list of values.
Throws:
  `java.io.IOException` - If the parameters could not be read.

#### readParameters

    public void readParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
                        throws java.io.IOException

Reads the parameters whose name is a key in the given map. If a matching parameter is found, its value is put in the map. If multiple values are found, a list is created and set in the map.

Parameters:
  `parameters` - The parameters map controlling the reading.
Throws:
  `java.io.IOException` - If the parameters could not be read.