Compiere 3.1

org.compiere.util
Class ByteArrayDataSource

java.lang.Object
  extended by org.compiere.util.ByteArrayDataSource
All Implemented Interfaces:
DataSource

public class ByteArrayDataSource
extends Object
implements DataSource

A DataSource based on the Java Mail Example. This class implements a DataSource from: an InputStream a byte array a String

Author:
John Mani, Bill Shannon, Max Spivak

Constructor Summary
ByteArrayDataSource(byte[] data, String type)
          Create a DataSource from a byte array
ByteArrayDataSource(InputStream is, String type)
          Create a DataSource from an input stream
ByteArrayDataSource(String stringData, String charSetName, String type)
          Create a DataSource from a String
 
Method Summary
 String getContentType()
          Get Content Type
 InputStream getInputStream()
          Return an InputStream for the data.
 String getName()
          Return Name or Class Name & Content Type
 OutputStream getOutputStream()
          Throws exception
 ByteArrayDataSource setName(String name)
          Set Name
 
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 DataSource from an input stream

Parameters:
is - stream
type - optional MIME type e.g. text/html

ByteArrayDataSource

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

Parameters:
data - data
type - type e.g. text/html

ByteArrayDataSource

public ByteArrayDataSource(String stringData,
                           String charSetName,
                           String type)
Create a DataSource from a String

Parameters:
stringData - content
charSetName - optional if null/empty uses UTF-8
type - optional MIME type e.g. text/html
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Return an InputStream for the data.

Specified by:
getInputStream in interface DataSource
Returns:
inputstream
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Throws exception

Specified by:
getOutputStream in interface DataSource
Returns:
null
Throws:
IOException

getContentType

public String getContentType()
Get Content Type

Specified by:
getContentType in interface DataSource
Returns:
MIME type e.g. text/html

setName

public ByteArrayDataSource setName(String name)
Set Name

Parameters:
name - name
Returns:
this

getName

public String getName()
Return Name or Class Name & Content Type

Specified by:
getName in interface DataSource
Returns:
dummy

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.