Andy,

Just for my interest, what's Rosiretto?
I only get one Google hit which is also you talking about it :o)


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 28 October 2005 15:05
To: [email protected]
Subject: Re: POI & JAF?


You may also want to take a look at Mime4J and Rosiretto since JAF (and 
hence javamail) do bad things to threads with regards to MIME.

-Andy

[EMAIL PROTECTED] wrote:
> Rob,
> 
> Here is the code I use, which I think covers what you are talking 
> about.
> 
> Iain
> 
> 
> ---------------------------------------
> import javax.activation.DataHandler;
> import javax.activation.DataSource;
> 
> DataSource dsData = new MemoryDataSource(
>                 poiByteArray, "foo.xls", "application/msexcel"); 
> DataHandler handler = new DataHandler(dsData);
> 
> 
> 
> ---------------------------------------
> File: MemoryDataSource.java
> 
> import java.io.ByteArrayInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
> 
> import org.apache.commons.lang.Validate;
> 
> /**
>  * A read-only DataSource that wraps a binary attachment, which is 
> already in
>  * memory and the MIME type is already known.
>  * <p>
>  * NB This refers to the Java Activation Framework's idea of 
> DataSources.
>  * Nothing to do with SQL. Java Mail uses this for framework to handle
>  * mail attachments.
>  * <p>
>  * The JAF 'activation.jar' must be present if this class is used.
>  *
>  * @see <a
> href="http://java.sun.com/products/javabeans/glasgow/jaf.html";>
>  *  Java Activation Framework</a>
>  */
> public class MemoryDataSource implements javax.activation.DataSource
> {
>     private byte[] data;
>     private String name;
>     private String mimeType;
>     
>     /**
>      * Creates a MemoryDataSource.
>      * @param data     Binary data. <b>NB - no defensive copy is
> made.</b>
>      * @param name     Some sort of filename for the data.
>      * @param mimeType MIME type of the data.
>      */
>     public MemoryDataSource(byte[] data, String name, String mimeType)
>     {
>         Validate.notNull(data, "data is null");
>         Validate.notEmpty(name, "name is null or empty");
>         Validate.notEmpty(mimeType, "mimeType is null or empty");
>         this.data = data;
>         this.name = name;
>         this.mimeType = mimeType;
>     }
>     
>     
>     /**
>      * @see javax.activation.DataSource#getContentType()
>      */
>     public String getContentType()
>     {
>         return mimeType;
>     }
> 
> 
>     /**
>      * @see javax.activation.DataSource#getInputStream()
>      */
>     public InputStream getInputStream() throws IOException
>     {
>         return new ByteArrayInputStream(data);
>     }
> 
> 
>     /**
>      * @see javax.activation.DataSource#getName()
>      */
>     public String getName()
>     {
>         return name;
>     }
> 
> 
>     /**
>      * Not implemented.
>      * @throws IOException Always.
>      * @see javax.activation.DataSource#getOutputStream()
>      */
>     public OutputStream getOutputStream() throws IOException
>     {
>         throw new IOException("Output is not implemented");
>     }
> 
> }
> 
> 
> 
> 
> -----Original Message-----
> From: Rob Cameron [mailto:[EMAIL PROTECTED]
> Sent: 28 October 2005 13:12
> To: [email protected]
> Subject: POI & JAF?
> 
> 
> Hi all,
> 
> I am wondering if POI can be applied to a problem I am having.
> 
> I have some content in memory that I want to email to the user as an 
> .xls attachment. Using javax.activation, I create a DataHandler, 
> passing my content and the appropriate mime type as parameters to the 
> constructor. For this to work properly, there needs to be a class 
> associated with x-java-content-handler for that mime type (inside 
> activation.jar in mailcap.default or elsewhere). This all works just 
> fine for a .txt attachment.
> 
> I am wondering if there is a class in POI (HSSF) that could be used as

> the x-java-content-handler for xls (application/msexcel). If not, I am

> wondering if anyone has any other ideas for how to approach this 
> issue.
> 
> Thanks,
> Rob Cameron
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
> 
> 
> ----------------------------------------------------------------------
> --
> For more information about Barclays Capital, please
> visit our web site at http://www.barcap.com.
> 
> 
> Internet communications are not secure and therefore the Barclays
> Group does not accept legal responsibility for the contents of this 
> message.  Although the Barclays Group operates anti-virus programmes, 
> it does not accept responsibility for any damage whatsoever that is 
> caused by viruses being passed.  Any views or opinions presented are 
> solely those of the author and do not necessarily represent those of
the 
> Barclays Group.  Replies to this email may be monitored by the
Barclays 
> Group for operational or business reasons.
> 
> ----------------------------------------------------------------------
> --
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to