org.enableit.tools.email.handlers
Class OctetStreamDataContentHandler
java.lang.Object
|
+--org.enableit.tools.email.handlers.OctetStreamDataContentHandler
- All Implemented Interfaces:
- javax.activation.DataContentHandler
- public class OctetStreamDataContentHandler
- extends java.lang.Object
- implements javax.activation.DataContentHandler
Data content handler for binary data types.
The J2EE documentation says that 'application/octet-stream' should
be specified as the mime type for unknown data types. This DCH, once
registered, while handle that type.
- Author:
- Tim Stephenson
Method Summary |
java.lang.Object |
getContent(javax.activation.DataSource ds)
Return an object representing the data in its most preferred form. |
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor df,
javax.activation.DataSource ds)
Returns an object which represents the data to be transferred. |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data
can be provided in. |
void |
writeTo(java.lang.Object obj,
java.lang.String mimeType,
java.io.OutputStream os)
Convert the object to a byte stream of the specified MIME type and
write it to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OctetStreamDataContentHandler
public OctetStreamDataContentHandler()
- Default Constructor.
getContent
public java.lang.Object getContent(javax.activation.DataSource ds)
throws java.io.IOException
- Return an object representing the data in its most preferred form.
- Specified by:
getContent
in interface javax.activation.DataContentHandler
- Parameters:
ds
- The datasource to get the content of.- Returns:
- The content (as a
byte[]
) - Throws:
java.io.IOException
- If there is a problem in reading the input.
getTransferData
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor df,
javax.activation.DataSource ds)
throws java.io.IOException
- Returns an object which represents the data to be transferred.
- Specified by:
getTransferData
in interface javax.activation.DataContentHandler
- Parameters:
df
- The DataFlavor
the datasource represents.ds
- The datasource to get the content of.- Returns:
- The content (as a
byte[]
) or null if the
DataFlavor does not match my internal one. - Throws:
java.io.IOException
- If there is a problem in reading the input.
getTransferDataFlavors
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
- Returns an array of DataFlavor objects indicating the flavors the data
can be provided in.
- Specified by:
getTransferDataFlavors
in interface javax.activation.DataContentHandler
- Returns:
- The
DataFlavors
this
DataContentHandler
can handle.
writeTo
public void writeTo(java.lang.Object obj,
java.lang.String mimeType,
java.io.OutputStream os)
throws java.io.IOException
- Convert the object to a byte stream of the specified MIME type and
write it to the output stream.
- Specified by:
writeTo
in interface javax.activation.DataContentHandler
- Parameters:
obj
- The content object (as a byte[]
) or null if the
DataFlavor does not match my internal one.mimeType
- The mime type of the data object.os
- OutputStream
to write the data object to.- Throws:
java.io.IOException
- If there is a problem in writing the output.
Copyright © 1999-2003 enableIT.org. All Rights Reserved.