Methods Summary |
---|
public java.lang.Object | getContent(javax.activation.DataSource ds)Return the content.
// create a new MimeMessage
try {
Session session;
if (ds instanceof MessageAware) {
MessageContext mc = ((MessageAware)ds).getMessageContext();
session = mc.getSession();
} else {
// Hopefully a rare case. Also hopefully the application
// has created a default Session that can just be returned
// here. If not, the one we create here is better than
// nothing, but overall not a really good answer.
session = Session.getDefaultInstance(new Properties(), null);
}
return new MimeMessage(session, ds.getInputStream());
} catch (MessagingException me) {
throw new IOException("Exception creating MimeMessage in " +
"message/rfc822 DataContentHandler: " + me.toString());
}
|
public java.lang.Object | getTransferData(java.awt.datatransfer.DataFlavor df, javax.activation.DataSource ds)return the Transfer Data of type DataFlavor from InputStream
// make sure we can handle this DataFlavor
if (ourDataFlavor.equals(df))
return getContent(ds);
else
return null;
|
public java.awt.datatransfer.DataFlavor[] | getTransferDataFlavors()return the DataFlavors for this DataContentHandler
return new DataFlavor[] { ourDataFlavor };
|
public void | writeTo(java.lang.Object obj, java.lang.String mimeType, java.io.OutputStream os)construct an object from a byte stream
(similar semantically to previous method, we are deciding
which one to support)
// if the object is a message, we know how to write that out
if (obj instanceof Message) {
Message m = (Message)obj;
try {
m.writeTo(os);
} catch (MessagingException me) {
throw new IOException(me.toString());
}
} else {
throw new IOException("unsupported object");
}
|