MDi JLib
1.7.4

com.microdeveloper.data
Class ByteArrayDataSource

java.lang.Object
  extended by com.microdeveloper.data.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ByteArrayDataSource
extends Object
implements javax.activation.DataSource

A simple byte data source object for stream operations.

Since:
1.0
Version:
1.0
Author:
MicroDeveloper, Inc.

Field Summary
(package private)  byte[] bytes
           
(package private)  String content
           
(package private)  String contentType
           
(package private)  String name
           
 
Constructor Summary
ByteArrayDataSource(byte[] bytes, String contentType, String name)
          Creates a new instance of ByteArrayDataSource and initializes it
ByteArrayDataSource(String content, String contentType)
          Creates a new instance of ByteArrayDataSource and initializes it using String element
 
Method Summary
 String getContentType()
          Returns the established content type
 InputStream getInputStream()
          Returns a new ByteArrayInputStream
 String getName()
          Returns the current name of the element
 OutputStream getOutputStream()
          Returns the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bytes

byte[] bytes

content

String content

contentType

String contentType

name

String name
Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(String content,
                           String contentType)
Creates a new instance of ByteArrayDataSource and initializes it using String element

Parameters:
content - content to establish
contentType - type of content (default is application/octet-stream)

ByteArrayDataSource

public ByteArrayDataSource(byte[] bytes,
                           String contentType,
                           String name)
Creates a new instance of ByteArrayDataSource and initializes it

Parameters:
bytes - byte array content to establish
contentType - type of content (default is application/octet-stream)
name - name to assign to the element
Method Detail

getContentType

public String getContentType()
Returns the established content type

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
String containing the current content type

getInputStream

public InputStream getInputStream()
Returns a new ByteArrayInputStream

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

getName

public String getName()
Returns the current name of the element

Specified by:
getName in interface javax.activation.DataSource
Returns:
String containing the name

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns the output stream. If the output stream file is not found, an FileNotFoundException is thrown.

Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
OutputStream handle
Throws:
IOException - thrown if the IO cannot be opened or read

MDi JLib
1.7.4

Copyright©2001-2007 MicroDeveloper, Inc. All Rights Reserved.