org.apache.turbine.util.mail
Class ByteArrayDataSource

java.lang.Object
  |
  +--org.apache.turbine.util.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

Version:
$Id$
Author:
Jon S. Stevens, Brett McLaughlin

Field Summary
private  java.io.ByteArrayOutputStream baos
           
private  byte[] data
          Data.
private  java.lang.String type
          Content-type.
 
Constructor Summary
ByteArrayDataSource(byte[] data, java.lang.String type)
          Create a datasource from a byte array.
ByteArrayDataSource(java.io.InputStream is, java.lang.String type)
          Create a datasource from an input stream.
ByteArrayDataSource(java.lang.String data, java.lang.String type)
          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 output stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

data

private byte[] data
Data.

type

private java.lang.String type
Content-type.

baos

private java.io.ByteArrayOutputStream baos
Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           java.lang.String type)
Create a datasource from a byte array.
Parameters:
data - A byte[].
type - A String.

ByteArrayDataSource

public ByteArrayDataSource(java.io.InputStream is,
                           java.lang.String type)
Create a datasource from an input stream.
Parameters:
is - An InputStream.
type - A String.

ByteArrayDataSource

public ByteArrayDataSource(java.lang.String data,
                           java.lang.String type)
Create a datasource from a String.
Parameters:
data - A String.
type - A String.
Method Detail

getContentType

public java.lang.String getContentType()
Get the content type.
Specified by:
getContentType in interface javax.activation.DataSource
Returns:
A String.

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:
IOException. -  

getName

public java.lang.String getName()
Get the name.
Specified by:
getName in interface javax.activation.DataSource
Returns:
A String.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get the output stream.
Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
An OutputStream.
Throws:
IOException. -  


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.