Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


org.apache.soap.util.mime
Class ByteArrayDataSource

java.lang.Object
  extended byorg.apache.soap.util.mime.ByteArrayDataSource


public class ByteArrayDataSource
extends java.lang.Object

This class implements a typed DataSource from an InputStream, a byte array, a String, a File.


Constructor Summary
ByteArrayDataSource(byte[] data, java.lang.String type)
Create a datasource from a byte array.
ByteArrayDataSource(java.io.File f, java.lang.String type)
Create a datasource from a File.
ByteArrayDataSource(java.io.InputStream is, java.lang.String type)
Create a datasource from an input stream.
ByteArrayDataSource(java.lang.String data, java.lang.String type)
Create a datasource from a String.

Method Summary
java.lang.String getContentType()
Get the content type.
java.io.InputStream getInputStream()
Return an InputStream to read the content.
java.lang.String getName()
getName() is not implemented.
java.io.OutputStream getOutputStream()
This DataSource cannot return an OutputStream, so this method is not implemented.
int getSize()
Return the number of bytes in the content.
java.lang.String getText()
Return the content as a String.
void setContentType(java.lang.String type)
Set the content type.
byte[] toByteArray()
Return the content as a byte array.
void writeTo(java.io.OutputStream os)
Write the content to an OutputStream.

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

ByteArrayDataSource

public ByteArrayDataSource(java.io.File f,
                           java.lang.String type)
                    throws java.io.IOException
Create a datasource from a File. If the Content-Type parameter is null, the type will be derived from the filename extension.
Parameters:
f - File object
type - Content-Type

ByteArrayDataSource

public ByteArrayDataSource(java.io.InputStream is,
                           java.lang.String type)
                    throws java.io.IOException
Create a datasource from an input stream.
Parameters:
is - InputStream
type - Content-Type

ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           java.lang.String type)
Create a datasource from a byte array.
Parameters:
data - byte array
type - Content-Type

ByteArrayDataSource

public ByteArrayDataSource(java.lang.String data,
                           java.lang.String type)
Create a datasource from a String. This method defaults to a String encoding of iso-8859-1. For a different encoding, specify a Mime "charset" in the Content-Type parameter.
Parameters:
data - byte array
type - Content-Type

Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Return an InputStream to read the content.
Returns:
an InputStream with the content
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
This DataSource cannot return an OutputStream, so this method is not implemented.
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
Get the content type.
Returns:
Content-Type string

setContentType

public void setContentType(java.lang.String type)
Set the content type.

getName

public java.lang.String getName()
getName() is not implemented.

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
Write the content to an OutputStream.
Parameters:
os - OutputStream to write the entire content to
Throws:
java.io.IOException

toByteArray

public byte[] toByteArray()
Return the content as a byte array.
Returns:
byte array with the content

getSize

public int getSize()
Return the number of bytes in the content.
Returns:
size of the byte array, or -1 if not set.

getText

public java.lang.String getText()
Return the content as a String. The Content-Type "charset" parameter will be used to determine the encoding, and if that's not available or invalid, "iso-8859-1".
Returns:
a String with the content

Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


Copyright © 2001 The Apache Software Foundation. All rights reserved.