org.apache.axiom.blob

## Interface MemoryBlob

- All Superinterfaces:
    Blob, WritableBlob

      public interface MemoryBlob
      extends WritableBlob

  Blob that stores data in memory.

  This interface redefines several methods from `Blob` and `WritableBlob` to not throw `IOException`. Also note that since data is stored in memory, calling `WritableBlob.release()` is not required.

  Instances are created with `Blobs.createMemoryBlob()`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `InputStream` | `getInputStream()` Get an input stream to read the data in the blob.
    `OutputStream` | `getOutputStream()` Create an output stream to write data to the blob.
    `long` | `getSize()` Get the size of the blob.
    `InputStream` | `readOnce()` Get an input stream that consumes the content of this blob.
    `void` | `release()` Release all resources held by this blob.

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

      `readFrom`

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

      `writeTo`

- - ### Method Detail

    - #### getInputStream

          InputStream getInputStream()

      Description copied from interface: `Blob`
      Get an input stream to read the data in the blob. A new `InputStream` object is returned each time this method is called, and the stream is positioned at the beginning of the data.
      Specified by:
        `getInputStream` in interface `Blob`
      Returns:
        the input stream to read the data from

    - #### getOutputStream

          OutputStream getOutputStream()

      Description copied from interface: `WritableBlob`
      Create an output stream to write data to the blob. The blob must be in state NEW when this method is called. It will be in state UNCOMMITTED after this method completes successfully. Note that this implies that this method may be called at most once for a given blob instance.

      Calls to methods of the returned output stream will modify the state of the blob according to the following rules:

      - A call to `OutputStream.close()` will change the state to COMMITTED.
      - Calls to other methods will not modify the state of the blob. They will result in an `IOException` if the state is COMMITTED, i.e. if the stream has already been closed.

      The returned stream may implement `ReadFromSupport`, especially if the blob stores its data in memory (in which case `ReadFromSupport.readFrom(InputStream, long)` would read data directly into the buffers managed by the blob).

      Specified by:
        `getOutputStream` in interface `WritableBlob`
      Returns:
        an output stream that can be used to write data to the blob

    - #### getSize

          long getSize()

      Description copied from interface: `Blob`
      Get the size of the blob.
      Specified by:
        `getSize` in interface `Blob`
      Returns:
        the number of bytes in the blob

    - #### release

          void release()

      Description copied from interface: `WritableBlob`
      Release all resources held by this blob. This method will put the blob into the RELEASED state and the content will no longer be accessible.
      Specified by:
        `release` in interface `WritableBlob`

    - #### readOnce

          InputStream readOnce()

      Get an input stream that consumes the content of this blob. The memory held by this blob will be gradually released as data is read from the stream.
      Returns:
        the input stream to read the data from

Copyright © The Apache Software Foundation. All Rights Reserved.