gnu.mail.handler
Class Multipart
java.lang.Object
gnu.mail.handler.Multipart
- DataContentHandler
public abstract class Multipart
extends java.lang.Object
implements DataContentHandler
A JAF data content handler for the multipart/* family of MIME content
types.
This provides the basic behaviour for any number of MimeMultipart-handling
subtypes which simply need to override their default constructor to provide
the correct MIME content-type and description.
protected DataFlavor | flavor - Our favorite data flavor.
|
Multipart(String mimeType, String description) - Constructor specifying the data flavor.
|
Object | getContent(DataSource source) - Return an object representing the data in its most preferred form.
|
Object | getTransferData(DataFlavor flavor, DataSource source) - Returns an object which represents the data to be transferred.
|
DataFlavor[] | getTransferDataFlavors() - Returns an array of DataFlavor objects indicating the flavors the data
can be provided in.
|
void | writeTo(Object object, String mimeType, OutputStream out) - Convert the object to a byte stream of the specified MIME type and
write it to the output stream.
|
flavor
protected DataFlavor flavor
Our favorite data flavor.
Multipart
protected Multipart(String mimeType,
String description)
Constructor specifying the data flavor.
mimeType
- the MIME content typedescription
- the description of the content type
getContent
public Object getContent(DataSource source)
throws IOException
Return an object representing the data in its most preferred form.
Generally this will be the form described by the first data flavor
returned by the getTransferDataFlavors
method.
source
- the data source representing the data to be converted
- a byte array
getTransferData
public Object getTransferData(DataFlavor flavor,
DataSource source)
throws UnsupportedFlavorException,
IOException
Returns an object which represents the data to be transferred.
The class of the object returned is defined by the representation class
of the flavor.
flavor
- the data flavor representing the requested typesource
- the data source representing the data to be converted
- the constructed object
getTransferDataFlavors
public DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data
can be provided in.
- the DataFlavors
writeTo
public void writeTo(Object object,
String mimeType,
OutputStream out)
throws IOException
Convert the object to a byte stream of the specified MIME type and
write it to the output stream.
object
- the object to be convertedmimeType
- the requested MIME content type to write asout
- the output stream into which to write the converted object