com.noelios.restlet.util
Class FormReader

java.lang.Object
  extended by com.noelios.restlet.util.FormReader

public class FormReader
extends Object

Form reader.

Author:
Jerome Louvel (contact@noelios.com)

Constructor Summary
FormReader(Logger logger, Representation representation)
          Constructor.
In case the representation does not define a character set, the UTF-8 character set is used.
FormReader(Logger logger, String query, CharacterSet characterSet)
          Constructor.
 
Method Summary
 void addParameters(Form form)
          Adds the parameters into a given form.
 Form read()
          Reads all the parameters.
 Parameter readFirstParameter(String name)
          Reads the first parameter with the given name.
 Parameter readNextParameter()
          Reads the next parameter available or null.
 Object readParameter(String name)
          Reads the parameters with the given name.
 void readParameters(Map<String,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(Logger logger,
                  Representation representation)
           throws IOException
Constructor.
In case the representation does not define a character set, the UTF-8 character set is used.

Parameters:
logger - The logger.
representation - The web form content.
Throws:
IOException

FormReader

public FormReader(Logger logger,
                  String query,
                  CharacterSet characterSet)
           throws IOException
Constructor.

Parameters:
logger - The logger.
query - The query string.
characterSet - The supported character encoding.
Throws:
IOException
Method Detail

readParameter

public Object readParameter(String name)
                     throws 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:
IOException

readFirstParameter

public Parameter readFirstParameter(String name)
                             throws IOException
Reads the first parameter with the given name.

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

readParameters

public void readParameters(Map<String,Object> parameters)
                    throws 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:
IOException

readNextParameter

public Parameter readNextParameter()
                            throws IOException
Reads the next parameter available or null.

Returns:
The next parameter available or null.
Throws:
IOException

read

public Form read()
          throws IOException
Reads all the parameters.

Returns:
The form read.
Throws:
IOException

addParameters

public void addParameters(Form form)
Adds the parameters into a given form.

Parameters:
form - The target form.


Copyright © 2005-2007 Noelios Technologies.