Package org.restlet.ext.html
Class FormDataSet
- java.lang.Object
-
public class FormDataSet extends OutputRepresentation
HTML form supporting either URL encoding or multipart encoding.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_BOUNDARYThe default boundary separating multipart entries.private Series<FormData>entriesThe modifiable series of data entries.private booleanmultipartIndicates if the form is multipart encoded.private java.lang.StringmultipartBoundaryThe boundary separating multipart entries.-
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description FormDataSet()Default constructor, creates a single part form.FormDataSet(java.lang.String multipartBoundary)Creates a multipart form.privateFormDataSet(MediaType mediaType, boolean multipart, java.lang.String multipartBoundary)Constructor.FormDataSet(Representation formRepresentation)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FormDataadd(java.lang.String name, java.lang.String value)Adds a new form data entry.private static MediaTypecreateMultipartMediaType(java.lang.String boundary)Creates the media type of a multipart form which must include the used boundary.java.lang.Stringencode()Encodes the form using the standard HTML form encoding mechanism and the UTF-8 character set.java.lang.Stringencode(boolean queryString)Encodes the form using the standard URI encoding mechanism and the UTF-8 character set.java.lang.Stringencode(char separator, boolean queryString)URL encodes the form.Series<FormData>getEntries()Returns the modifiable series of form entries.java.lang.StringgetMatrixString()Formats the form as a matrix path string.java.lang.StringgetMultipartBoundary()Returns the boundary separating multipart entries.java.lang.StringgetQueryString()Formats the form as a query string.booleanisMultipart()Indicates if the form is multipart encoded.voidsetMultipart(boolean multipart)Indicates if the form is multipart encoded.voidsetMultipartBoundary(java.lang.String boundary)Sets the boundary separating multipart entries.voidwrite(java.io.OutputStream outputStream)Writes the representation to a byte stream.-
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, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
-
-
-
-
Field Detail
-
DEFAULT_BOUNDARY
private static final java.lang.String DEFAULT_BOUNDARY
The default boundary separating multipart entries.- See Also:
- Constant Field Values
-
multipart
private volatile boolean multipart
Indicates if the form is multipart encoded.
-
multipartBoundary
private volatile java.lang.String multipartBoundary
The boundary separating multipart entries.
-
-
Constructor Detail
-
FormDataSet
public FormDataSet()
Default constructor, creates a single part form.
-
FormDataSet
private FormDataSet(MediaType mediaType, boolean multipart, java.lang.String multipartBoundary)
Constructor.- Parameters:
mediaType- The representation's mediaType.multipart- Indicates if the form is multipart encoded.multipartBoundary- The boundary separating multipart entries.
-
FormDataSet
public FormDataSet(Representation formRepresentation)
Constructor.- Parameters:
formRepresentation- The representation to parse.
-
FormDataSet
public FormDataSet(java.lang.String multipartBoundary)
Creates a multipart form.- Parameters:
multipartBoundary- The boundary separating multipart entries.
-
-
Method Detail
-
createMultipartMediaType
private static MediaType createMultipartMediaType(java.lang.String boundary)
Creates the media type of a multipart form which must include the used boundary.- Parameters:
boundary- The multipart boundary.- Returns:
- The multipart media type.
-
add
public FormData add(java.lang.String name, java.lang.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 java.lang.String encode() throws java.io.IOExceptionEncodes the form using the standard HTML form encoding mechanism and the UTF-8 character set.- Returns:
- The encoded form.
- Throws:
java.io.IOException
-
encode
public java.lang.String encode(boolean queryString) throws java.io.IOExceptionEncodes 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:
java.io.IOException
-
encode
public java.lang.String encode(char separator, boolean queryString) throws java.io.IOExceptionURL 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:
java.io.IOException
-
getEntries
public Series<FormData> getEntries()
Returns the modifiable series of form entries.- Returns:
- The modifiable series of form entries.
-
getMatrixString
public java.lang.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 java.lang.String getMultipartBoundary()
Returns the boundary separating multipart entries.- Returns:
- The boundary separating multipart entries.
-
getQueryString
public java.lang.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(java.lang.String boundary)
Sets the boundary separating multipart entries.- Parameters:
boundary- The boundary separating multipart entries.
-
write
public void write(java.io.OutputStream outputStream) throws java.io.IOExceptionDescription copied from class:RepresentationWrites the representation to a byte stream. This method is ensured to write the full content for each invocation unless it is a transient representation, in which case an exception is thrown.
Note that the class implementing this method shouldn't flush or close the givenOutputStreamafter writing to it as this will be handled by the Restlet connectors automatically.- Specified by:
writein classRepresentation- Parameters:
outputStream- The output stream.- Throws:
java.io.IOException
-
-