org.restlet.ext.html
Class FormDataSet

java.lang.Object
  extended by org.restlet.representation.Variant
      extended by org.restlet.representation.RepresentationInfo
          extended by org.restlet.representation.Representation
              extended by org.restlet.representation.StreamRepresentation
                  extended by org.restlet.representation.OutputRepresentation
                      extended by org.restlet.ext.html.FormDataSet

public class FormDataSet
extends OutputRepresentation

HTML form supporting either URL encoding or multipart encoding.

Author:
Jerome Louvel

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
FormDataSet()
          Default constructor, creates a single part form.
FormDataSet(Representation formRepresentation)
          Constructor.
FormDataSet(String multipartBoundary)
          Creates a multipart form.
 
Method Summary
 FormData add(String name, String value)
          Adds a new form data entry.
 String encode()
          Encodes the form using the standard HTML form encoding mechanism and the UTF-8 character set.
 String encode(boolean queryString)
          Encodes the form using the standard URI encoding mechanism and the UTF-8 character set.
 String encode(char separator, boolean queryString)
          URL encodes the form.
 Series<FormData> getEntries()
          Returns the modifiable series of form entries.
 String getMatrixString()
          Formats the form as a matrix path string.
 String getMultipartBoundary()
          Returns the boundary separating multipart entries.
 String getQueryString()
          Formats the form as a query string.
 boolean isMultipart()
          Indicates if the form is multipart encoded.
 void setMultipart(boolean multipart)
          Indicates if the form is multipart encoded.
 void setMultipartBoundary(String boundary)
          Sets the boundary separating multipart entries.
 void write(OutputStream outputStream)
           
 
Methods inherited from class org.restlet.representation.OutputRepresentation
getChannel, getStream
 
Methods inherited from class org.restlet.representation.StreamRepresentation
getReader, write, write
 
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
 
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
 
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormDataSet

public FormDataSet()
Default constructor, creates a single part form.


FormDataSet

public FormDataSet(Representation formRepresentation)
Constructor.

Parameters:
formRepresentation - The representation to parse.

FormDataSet

public FormDataSet(String multipartBoundary)
Creates a multipart form.

Parameters:
multipartBoundary - The boundary separating multipart entries.
Method Detail

add

public FormData add(String name,
                    String value)
Adds a new form data entry.

Parameters:
name - The entry name.
value - The entry value.
Returns:
The entry created and added to getEntries().

encode

public String encode()
              throws IOException
Encodes the form using the standard HTML form encoding mechanism and the UTF-8 character set.

Returns:
The encoded form.
Throws:
IOException

encode

public String encode(boolean queryString)
              throws IOException
Encodes the form using the standard URI encoding mechanism and the UTF-8 character set.

Parameters:
queryString - True if the target is a query string.
Returns:
The encoded form.
Throws:
IOException

encode

public String encode(char separator,
                     boolean queryString)
              throws IOException
URL encodes the form.

Parameters:
separator - The separator character to append between parameters.
queryString - True if the target is a query string.
Returns:
The encoded form.
Throws:
IOException

getEntries

public Series<FormData> getEntries()
Returns the modifiable series of form entries.

Returns:
The modifiable series of form entries.

getMatrixString

public String getMatrixString()
Formats the form as a matrix path string. Uses UTF-8 as the character set for encoding non-ASCII characters.

Returns:
The form as a matrix string.
See Also:
Matrix URIs by Tim Berners Lee

getMultipartBoundary

public String getMultipartBoundary()
Returns the boundary separating multipart entries.

Returns:
The boundary separating multipart entries.

getQueryString

public String getQueryString()
Formats the form as a query string. Uses UTF-8 as the character set for encoding non-ASCII characters.

Returns:
The form as a query string.

isMultipart

public boolean isMultipart()
Indicates if the form is multipart encoded.

Returns:
True if the form is multipart encoded.

setMultipart

public void setMultipart(boolean multipart)
Indicates if the form is multipart encoded.

Parameters:
multipart - True if the form is multipart encoded.

setMultipartBoundary

public void setMultipartBoundary(String boundary)
Sets the boundary separating multipart entries.

Parameters:
boundary - The boundary separating multipart entries.

write

public void write(OutputStream outputStream)
           throws IOException
Specified by:
write in class Representation
Throws:
IOException


Copyright © 2005-2013 Restlet.