org.apache.commons.mail
Class ByteArrayDataSource

java.lang.Object
  extended byorg.apache.commons.mail.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ByteArrayDataSource
extends java.lang.Object
implements javax.activation.DataSource

This class implements a typed DataSource from:
- an InputStream
- a byte array
- a String

Since:
1.0
Version:
$Id: ByteArrayDataSource.java 225600 2005-07-27 20:16:23Z rdonkin $
Author:
Colin Chalmers, Jon S. Stevens, Brett McLaughlin

Field Summary
private  java.io.ByteArrayOutputStream baos
          Stream containg the Data
static int BUFFER_SIZE
          define the buffer size
private  java.lang.String type
          Content-type.
 
Constructor Summary
ByteArrayDataSource(byte[] data, java.lang.String aType)
          Create a datasource from a byte array.
ByteArrayDataSource(java.io.InputStream aIs, java.lang.String aType)
          Create a datasource from an input stream.
ByteArrayDataSource(java.lang.String data, java.lang.String aType)
          Create a datasource from a String.
 
Method Summary
private  void byteArrayDataSource(java.io.InputStream aIs, java.lang.String aType)
          Create a datasource from an input stream.
 java.lang.String getContentType()
          Get the content type.
 java.io.InputStream getInputStream()
          Get the input stream.
 java.lang.String getName()
          Get the name.
 java.io.OutputStream getOutputStream()
          Get the OutputStream to write to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
define the buffer size

See Also:
Constant Field Values

baos

private java.io.ByteArrayOutputStream baos
Stream containg the Data


type

private java.lang.String type
Content-type.

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           java.lang.String aType)
                    throws java.io.IOException
Create a datasource from a byte array.

Parameters:
data - A byte[].
aType - A String.
Throws:
java.io.IOException - IOException
Since:
1.0

ByteArrayDataSource

public ByteArrayDataSource(java.io.InputStream aIs,
                           java.lang.String aType)
                    throws java.io.IOException
Create a datasource from an input stream.

Parameters:
aIs - An InputStream.
aType - A String.
Throws:
java.io.IOException - IOException
Since:
1.0

ByteArrayDataSource

public ByteArrayDataSource(java.lang.String data,
                           java.lang.String aType)
                    throws java.io.IOException
Create a datasource from a String.

Parameters:
data - A String.
aType - A String.
Throws:
java.io.IOException - IOException
Since:
1.0
Method Detail

byteArrayDataSource

private void byteArrayDataSource(java.io.InputStream aIs,
                                 java.lang.String aType)
                          throws java.io.IOException
Create a datasource from an input stream.

Parameters:
aIs - An InputStream.
aType - A String.
Throws:
java.io.IOException - IOException

getContentType

public java.lang.String getContentType()
Get the content type.

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
A String.
Since:
1.0

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get the input stream.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
An InputStream.
Throws:
java.io.IOException - IOException
Since:
1.0

getName

public java.lang.String getName()
Get the name.

Specified by:
getName in interface javax.activation.DataSource
Returns:
A String.
Since:
1.0

getOutputStream

public java.io.OutputStream getOutputStream()
Get the OutputStream to write to

Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
An OutputStream
Since:
1.0