Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle® Application Server XML Java API Reference 10g Release 2 (10.1.2) Part no. B12024-03 September 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.soap.util.mime
Class ByteArrayDataSource

    java.lang.Object
      |
      +--org.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
    `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.
    `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
    `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

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle® Application Server XML Java API Reference 10g Release 2 (10.1.2) Part no. B12024-03 September 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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