net.suberic.crypto
Class ByteArrayDataSource

java.lang.Object
  extended bynet.suberic.crypto.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

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

A DataSource based off of a byte array.


Constructor Summary
ByteArrayDataSource(byte[] newContent, java.lang.String newName, java.lang.String newContentType)
          Creates a ByteArrayDataSource from the given byte array.
 
Method Summary
 java.lang.String getContentType()
          This method returns the MIME type of the data in the form of a string.
 java.io.InputStream getInputStream()
          Returns a new ByteArrayInputStream based off of the byte array given as content.
 java.lang.String getName()
          Return the name of this object where the name of the object is dependant on the nature of the underlying objects.
 java.io.OutputStream getOutputStream()
          This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(byte[] newContent,
                           java.lang.String newName,
                           java.lang.String newContentType)
Creates a ByteArrayDataSource from the given byte array.

Method Detail

getContentType

public java.lang.String getContentType()
This method returns the MIME type of the data in the form of a string. For this implementation, this is the type that is set in the constructor.

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
the MIME type

getInputStream

public java.io.InputStream getInputStream()
Returns a new ByteArrayInputStream based off of the byte array given as content.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
a ByteArrayInputStream

getName

public java.lang.String getName()
Return the name of this object where the name of the object is dependant on the nature of the underlying objects.

Specified by:
getName in interface javax.activation.DataSource
Returns:
the name given in the constructor

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so. Not appropriate for this implementation; throws an IOException.

Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
an OutputStream
Throws:
java.io.IOException