Class BlobLocatorInputStream

java.lang.Object
java.io.InputStream
org.apache.derby.client.am.BlobLocatorInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

class BlobLocatorInputStream extends InputStream
An InputStream that will use an locator to fetch the Blob value from the server.

Closing a ByteArrayInputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

This InputStream implementation is pretty basic. No buffering of data is done. Hence, for efficiency #read(byte[]) should be used instead of #read(). Marks are not supported, but it should be pretty simple to extend the implementation to support this. A more efficient skip implementation should also be straight-forward.

  • Field Details

    • connection

      private final ClientConnection connection
      Connection used to read Blob from server.
    • blob

      private final ClientBlob blob
      The Blob to be accessed.
    • currentPos

      private long currentPos
      Current position in the underlying Blob. Blobs are indexed from 1
    • maxPos

      private final long maxPos
      Position in Blob where to stop reading. maxPos starts counting from 1.
  • Constructor Details

    • BlobLocatorInputStream

      BlobLocatorInputStream(ClientConnection connection, ClientBlob blob) throws SqlException
      Create an InputStream for reading the Blob value represented by the given locator based Blob object.
      Parameters:
      connection - connection to be used to read the Blob value from the server
      blob - Blob object that contains locator for the Blob value on the server.
      Throws:
      SqlException - if an error occurs when obtaining the length of the Blob.
    • BlobLocatorInputStream

      BlobLocatorInputStream(ClientConnection connection, ClientBlob blob, long position, long length) throws SqlException
      Create an InputStream for reading the Blob value represented by the given locator based Blob object.
      Parameters:
      connection - connection to be used to read the Blob value from the server
      blob - Blob object that contains locator for the Blob value on the server.
      position - the position in the Blob of the first byte to read.
      length - the maximum number of bytes to read from the Blob.
      Throws:
      SqlException - if an error occurs when obtaining the length of the Blob.
  • Method Details