com.groiss.util
Class ByteArrayDataSource

java.lang.Object
  extended by com.groiss.util.ByteArrayDataSource
All Implemented Interfaces:
DataSource

public class ByteArrayDataSource
extends Object
implements DataSource

A DataSource that can be created out of a byte array, a String or an input stream.


Constructor Summary
ByteArrayDataSource(byte[] data, String type)
          Create a DataSource from a byte array.
ByteArrayDataSource(InputStream is, String type)
          Create a DataSoruce from an input stream.
ByteArrayDataSource(String data, String type)
          Create a DataSource from a String.
 
Method Summary
 String getContentType()
          Returns the content type for this data source.
 InputStream getInputStream()
          Returns an InputStream for reading from this data source.
 String getName()
          Returns the name of the data source.
 OutputStream getOutputStream()
          This operation is not supported!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(InputStream is,
                           String type)
Create a DataSoruce from an input stream.

Parameters:
is - InputStream from which the data will be read.
type - Mime-Type of the data (e.g., "application/pdf").

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           String type)
Create a DataSource from a byte array.

Parameters:
data - byte array holding the data for this data source. The byte array will not be copied but used directly.
type - Mime-Type of the data (e.g., "application/pdf").

ByteArrayDataSource

public ByteArrayDataSource(String data,
                           String type)
Create a DataSource from a String.

Parameters:
data - String holding the data for this data source.
type - Mime-Type of the data (e.g., "application/pdf").
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns an InputStream for reading from this data source.

Specified by:
getInputStream in interface DataSource
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
This operation is not supported! If you call it, an IOException will be thrown.

Specified by:
getOutputStream in interface DataSource
Throws:
IOException

getContentType

public String getContentType()
Returns the content type for this data source.

Specified by:
getContentType in interface DataSource

getName

public String getName()
Returns the name of the data source. Current implementation returns always "dummy", because there is no need for a name.

Specified by:
getName in interface DataSource


@enterprise 8.0.10078 Copyright © 2001-2011 Groiss Informatics GmbH. All Rights Reserved.