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 480401 2006-11-29 04:40:04Z bayard $
Author:
Colin Chalmers, Jon S. Stevens, Brett McLaughlin

Field Summary
static int BUFFER_SIZE
          define the buffer size
 
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
 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
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

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


Copyright © 2001-2007 The Apache Software Foundation. All Rights Reserved.