com.arsdigita.mail
Class ByteArrayDataSource

java.lang.Object
  extended bycom.arsdigita.mail.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ByteArrayDataSource
extends Object
implements javax.activation.DataSource

Provides a simple DataSource that allows in-memory data objects to be attached to a mail message.

Based on the sample code distributed with the JavaMail 1.2 API.

Version:
$Id: //core-platform/dev/src/com/arsdigita/mail/ByteArrayDataSource.java#7 $
Author:
Ron Henderson

Constructor Summary
ByteArrayDataSource(byte[] data, String type, String name)
          Creates a data source from a byte array.
ByteArrayDataSource(InputStream is, String type, String name)
          Creates a data source from an input stream.
ByteArrayDataSource(String data, String type, String name)
          Creates a data source from a String, assuming the data only contains ASCII characters (iso-8859-1).
ByteArrayDataSource(String data, String type, String name, String charset)
          Creates a data source from a String using a specified character set.
 
Method Summary
 String getContentType()
          Returns the MIME type of the content.
 InputStream getInputStream()
          Returns an input stream for the data.
 String getName()
          Returns the name of the content.
 OutputStream getOutputStream()
          Required by the interface, but not available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(InputStream is,
                           String type,
                           String name)
Creates a data source from an input stream.

Parameters:
is - the InputStream to read from
type - the MIME type of the data
name - the name of the data

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           String type,
                           String name)
Creates a data source from a byte array.

Parameters:
data - the byte array containing the data
type - the MIME type of the data
name - the name of the data

ByteArrayDataSource

public ByteArrayDataSource(String data,
                           String type,
                           String name)
Creates a data source from a String, assuming the data only contains ASCII characters (iso-8859-1).

Parameters:
data - the String containing the data
type - the MIME type of the data
name - the name of the data

ByteArrayDataSource

public ByteArrayDataSource(String data,
                           String type,
                           String name,
                           String charset)
Creates a data source from a String using a specified character set.

Parameters:
data - the String containing the data
type - the MIME type of the data
name - the name of the data
charset - the encoding used for the String
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns an input stream for the data.

Specified by:
getInputStream in interface javax.activation.DataSource
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Required by the interface, but not available.

Specified by:
getOutputStream in interface javax.activation.DataSource
Throws:
IOException

getContentType

public String getContentType()
Returns the MIME type of the content.

Specified by:
getContentType in interface javax.activation.DataSource

getName

public String getName()
Returns the name of the content.

Specified by:
getName in interface javax.activation.DataSource


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC