Package org.apache.axiom.blob

# Class AbstractWritableBlob

java.lang.Object
org.apache.axiom.blob.AbstractWritableBlob

All Implemented Interfaces:
  `Blob`, `WritableBlob`

public abstract class AbstractWritableBlob extends Object implements WritableBlob
Partial implementation of the `WritableBlob` interface that implements `WritableBlob.readFrom(InputStream)` using `WritableBlob.getOutputStream()` and `Blob.writeTo(OutputStream)` using `Blob.getInputStream()`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractWritableBlob()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `readFrom(InputStream in)`
  Read data from the given input stream and write it to the blob.
  `void`
  `writeTo(OutputStream out)`
  Write the data to a given output stream.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.axiom.blob.Blob

  `getInputStream, getSize`

  ### Methods inherited from interface org.apache.axiom.blob.WritableBlob

  `getOutputStream, release`

- ## Constructor Details

  - ### AbstractWritableBlob

    public AbstractWritableBlob()

- ## Method Details

  - ### readFrom

    public long readFrom(InputStream in) throws org.apache.axiom.ext.io.StreamCopyException
    Description copied from interface: `WritableBlob`
    Read data from the given input stream and write it to the blob.

    A call to this method has the same effect as requesting an output stream using `WritableBlob.getOutputStream()` and copying the data from the input stream to that output stream, but the implementation may achieve this result in a more efficient way.

    The blob must be in state NEW when this method is called. It will be in state COMMITTED after this method completes successfully.

    The method transfers data from the input stream to the blob until the end of the input stream is reached.

    Specified by:
      `readFrom` in interface `WritableBlob`
    Parameters:
      `in` - An input stream to read data from. This method will not close the stream.
    Returns:
      the number of bytes transferred
    Throws:
      `org.apache.axiom.ext.io.StreamCopyException`

  - ### writeTo

    public void writeTo(OutputStream out) throws org.apache.axiom.ext.io.StreamCopyException
    Description copied from interface: `Blob`
    Write the data to a given output stream. This method can be called multiple times, i.e. it doesn't consume the content.
    Specified by:
      `writeTo` in interface `Blob`
    Parameters:
      `out` - The output stream to write the data to. This method will not close the stream.
    Throws:
      `org.apache.axiom.ext.io.StreamCopyException` - Thrown if there is an I/O when reading the data from the blob or when writing it to the stream. `StreamCopyException.getOperation()` can be used to determine whether the failed operation was a read or a write.