OpMath

com.opmath.mail
Class ByteArrayDataSource

java.lang.Object
  |
  +--com.opmath.mail.ByteArrayDataSource
All Implemented Interfaces:
DataSource

public class ByteArrayDataSource
extends Object
implements DataSource

A DataSource that can act as a DataHandler for an email MimeBodyPart.

The com.opmath.mail.ByteArrayDataSource class implements the javax.activation.DataSource interface.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3
Version:
1.0
Author:
Bruno Beloff bruno.beloff@opmath.com

Constructor Summary
ByteArrayDataSource(byte[] data, String type)
          Constructs a ByteArrayDataSource instance.
ByteArrayDataSource(InputStream inStrm, String type)
          Constructs a ByteArrayDataSource instance.
ByteArrayDataSource(String inStr, String type)
          Constructs a ByteArrayDataSource instance.
 
Method Summary
 String getContentType()
          Returns the MIME type of this instance's data.
 InputStream getInputStream()
          Returns a new ByteArrayInputStream, based on this instance's data.
 String getName()
          Returns the name of the file from which the data dispensed by this ByteArrayDataSource originated.
 OutputStream getOutputStream()
          Not supported by this class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(InputStream inStrm,
                           String type)
                    throws IOException
Constructs a ByteArrayDataSource instance. Data will is obtained from an InputStream. If the InputStream cannot be read, the constructor will throw an IOException.

Parameters:
inStrm - the InputStream carrying the data.
type - the String identifying the MIME type.
Throws:
java.util.IOException - An exception thrown if the InputStream cannot be read.
Since:
JDK 1.2.2

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           String type)
Constructs a ByteArrayDataSource instance. Data will is obtained from a byte[] - in other words, no data transformation takes place.

Parameters:
data - the byte[] carrying the data.
type - the String identifying the MIME type.
Since:
JDK 1.2.2

ByteArrayDataSource

public ByteArrayDataSource(String inStr,
                           String type)
                    throws IOException
Constructs a ByteArrayDataSource instance. Data will is obtained from an String. If the String cannot be translated, the constructor will throw an IOException.

Parameters:
inStr - the String carrying the data.
type - the String identifying the MIME type.
Throws:
java.util.IOException - An exception thrown if the String cannot be translated.
Since:
JDK 1.2.2
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns a new ByteArrayInputStream, based on this instance's data.

Specified by:
getInputStream in interface DataSource
Returns:
a new ByteArrayInputStream.
Throws:
java.util.IOException - An exception thrown if the data is null.
Since:
JDK 1.2.2

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Not supported by this class.

Specified by:
getOutputStream in interface DataSource
Returns:
a new OutputStream. (Formally only.)
Throws:
java.util.IOException - Always.
Since:
JDK 1.2.2

getContentType

public String getContentType()
Returns the MIME type of this instance's data.

Specified by:
getContentType in interface DataSource
Returns:
a String indicating the MIME type.
Since:
JDK 1.2.2

getName

public String getName()
Returns the name of the file from which the data dispensed by this ByteArrayDataSource originated. For this class, the file is not identified.

Specified by:
getName in interface DataSource
Returns:
a String equal to "anonymous ByteArrayDataSource instance".
Since:
JDK 1.2.2

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK