FileDocCategorySizeDatePackage
message_rfc822.javaAPI DocGlassfish v2 API4512Mon May 14 15:28:42 BST 2007com.sun.mail.handlers

message_rfc822

public class message_rfc822 extends Object implements DataContentHandler
version
1.9, 07/05/04
author
Christopher Cotton

Fields Summary
ActivationDataFlavor
ourDataFlavor
Constructors Summary
Methods Summary
public java.lang.ObjectgetContent(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.ObjectgetTransferData(java.awt.datatransfer.DataFlavor df, javax.activation.DataSource ds)
return the Transfer Data of type DataFlavor from InputStream

param
df The DataFlavor.
param
ins The InputStream corresponding to the data.
return
a Message object

	// 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
The DataFlavors.


                  
       
	return new DataFlavor[] { ourDataFlavor };
    
public voidwriteTo(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");
	}