Expresso 5-5-0

com.jcorporate.expresso.core.misc
Class ByteArrayDataSource

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ByteArrayDataSource
extends Object
implements javax.activation.DataSource

Used to create a generic raw virtual DataSource for the MIME mail messages.

Version:
$Id: ByteArrayDataSource.java,v 1.2 2004/02/11 06:14:07 lhamel Exp $
Author:
Peter Pilgrim, Tue Feb 10 01:37:59 GMT 2004, Sun MicroSystem, JavaMail Demo, 2001

Constructor Summary
ByteArrayDataSource(byte[] data, String type, String name)
          Create a DataSource from raw data bytes
ByteArrayDataSource(String text, String type, String name)
          Create a DataSource from a text String
 
Method Summary
 String getContentType()
          Returns the content type (mime type)
 InputStream getInputStream()
          Returns the input stream associated with the data source
 String getName()
          Returns the name of the data source.
 OutputStream getOutputStream()
          Returns the output stream associated with the data source
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           String type,
                           String name)
Create a DataSource from raw data bytes

Parameters:
data - is the contents of the mail message
type - is the mime-type such as text/html
name - the name of the attachment (ie a filename)

ByteArrayDataSource

public ByteArrayDataSource(String text,
                           String type,
                           String name)
Create a DataSource from a text String

Parameters:
type - is the mime-type such as text/html
name - the name of the attachment (ie a filename)
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns the input stream associated with the data source

Specified by:
getInputStream in interface javax.activation.DataSource
Throws:
IOException - if there is I/O error

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns the output stream associated with the data source

Specified by:
getOutputStream in interface javax.activation.DataSource
Throws:
IOException - always raised because by definition a data source is not a data sink!

getContentType

public String getContentType()
Returns the content type (mime type)

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
content type as text

getName

public String getName()
Returns the name of the data source.

Specified by:
getName in interface javax.activation.DataSource
Returns:
the releveant name of the raw data

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.