Class FBBlob

java.lang.Object
org.firebirdsql.jdbc.FBBlob
All Implemented Interfaces:
Blob, TransactionListener, FirebirdBlob, Synchronizable

public class FBBlob extends Object implements FirebirdBlob, TransactionListener, Synchronizable
Firebird implementation of Blob.
  • Field Details

  • Constructor Details

    • FBBlob

      public FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener)
      Create new Blob instance. This constructor creates new fresh Blob, only writing to the Blob is allowed.
      Parameters:
      c - connection that will be used to write data to blob
      blobListener - Blob listener instance
    • FBBlob

      public FBBlob(GDSHelper c)
      Create new Blob instance. This constructor creates new fresh Blob, only writing to the Blob is allowed.
      Parameters:
      c - connection that will be used to write data to blob.
    • FBBlob

      public FBBlob(GDSHelper c, long blob_id, FBObjectListener.BlobListener blobListener)
      Create instance of this class to access existing Blob.
      Parameters:
      c - connection that will be used to access Blob.
      blob_id - ID of the Blob.
      blobListener - Blob listener instance
    • FBBlob

      public FBBlob(GDSHelper c, long blob_id)
      Create instance of this class to access existing Blob.
      Parameters:
      c - connection that will be used to access Blob.
      blob_id - ID of the Blob.
  • Method Details

    • getSynchronizationObject

      public final Object getSynchronizationObject()
      Description copied from interface: Synchronizable
      Get synchronization object.
      Specified by:
      getSynchronizationObject in interface Synchronizable
      Returns:
      object, cannot be null.
    • free

      public void free() throws SQLException
      Specified by:
      free in interface Blob
      Throws:
      SQLException
    • getBinaryStream

      public InputStream getBinaryStream(long pos, long length) throws SQLException
      Specified by:
      getBinaryStream in interface Blob
      Throws:
      SQLException
    • getInfo

      public byte[] getInfo(byte[] items, int buffer_length) throws SQLException
      Get information about this Blob. This method should be considered as temporary because it provides access to low-level API. More information on how to use the API can be found in "API Guide".
      Parameters:
      items - items in which we are interested.
      buffer_length - buffer where information will be stored.
      Returns:
      array of bytes containing information about this Blob.
      Throws:
      SQLException - if something went wrong.
    • length

      public long length() throws SQLException
      Specified by:
      length in interface Blob
      Throws:
      SQLException
    • isSegmented

      public boolean isSegmented() throws SQLException
      Description copied from interface: FirebirdBlob
      Check if blob is segmented. If Blob is segmented, you cannot use FirebirdBlob.BlobInputStream.seek(int) method.
      Specified by:
      isSegmented in interface FirebirdBlob
      Returns:
      true if this blob is segmented, otherwise false
      Throws:
      SQLException
    • detach

      public FirebirdBlob detach() throws SQLException
      Description copied from interface: FirebirdBlob
      Detach this blob. This method creates new instance of the same blob database object that is not under result set control. When result set is closed, all associated resources are also released, including open blob streams. This method creates an new instance of blob object with the same blob ID that can be used even when result set is closed.

      Note, detached blob will not remember the stream position of this object. This means that you cannot start reading data from the blob, then detach it, and then continue reading. Reading from detached blob will begin at the blob start.

      Specified by:
      detach in interface FirebirdBlob
      Returns:
      instance of FirebirdBlob that is not under result set control.
      Throws:
      SQLException - if Blob cannot be detached.
    • getBytes

      public byte[] getBytes(long pos, int length) throws SQLException
      Specified by:
      getBytes in interface Blob
      Throws:
      SQLException
    • getBinaryStream

      public InputStream getBinaryStream() throws SQLException
      Specified by:
      getBinaryStream in interface Blob
      Throws:
      SQLException
    • position

      public long position(byte[] pattern, long start) throws SQLException
      Specified by:
      position in interface Blob
      Throws:
      SQLException
    • position

      public long position(Blob pattern, long start) throws SQLException
      Specified by:
      position in interface Blob
      Throws:
      SQLException
    • truncate

      public void truncate(long len) throws SQLException
      Specified by:
      truncate in interface Blob
      Throws:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] bytes) throws SQLException
      Specified by:
      setBytes in interface Blob
      Throws:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
      Specified by:
      setBytes in interface Blob
      Throws:
      SQLException
    • setBinaryStream

      public OutputStream setBinaryStream(long pos) throws SQLException
      Specified by:
      setBinaryStream in interface Blob
      Throws:
      SQLException
    • getBlobId

      public long getBlobId() throws SQLException
      Get the identifier for this Blob
      Returns:
      This Blob's identifier
      Throws:
      SQLException - if a database access error occurs
    • copyBytes

      public void copyBytes(byte[] bytes, int pos, int len) throws SQLException
      Throws:
      SQLException
    • getGdsHelper

      public GDSHelper getGdsHelper()
    • copyStream

      public void copyStream(InputStream inputStream, long length) throws SQLException
      Copy the contents of an InputStream into this Blob.

      Calling with length -1 is equivalent to calling copyStream(InputStream), and will copy the whole stream.

      Parameters:
      inputStream - the stream from which data will be copied
      length - The maximum number of bytes to read from the InputStream, -1 to read whole stream
      Throws:
      SQLException - if a database access error occurs
    • copyStream

      public void copyStream(InputStream inputStream) throws SQLException
      Copy the contents of an InputStream into this Blob. Unlike the copyStream(InputStream, long) method, this one copies bytes until the EOF is reached.
      Parameters:
      inputStream - the stream from which data will be copied
      Throws:
      SQLException - if a database access error occurs
    • copyCharacterStream

      public void copyCharacterStream(Reader reader, long length, Encoding encoding) throws SQLException
      Copy data from a character stream into this Blob.

      Calling with length -1 is equivalent to calling copyCharacterStream(Reader, Encoding).

      Parameters:
      reader - the source of data to copy
      length - The maximum number of bytes to copy, or -1 to read the whole stream
      encoding - The encoding used in the character stream
      Throws:
      SQLException
    • copyCharacterStream

      public void copyCharacterStream(Reader reader, Encoding encoding) throws SQLException
      Copy data from a character stream into this Blob. Unlike the copyCharacterStream(Reader, long, Encoding) )} method, this one copies bytes until the EOF is reached.
      Parameters:
      reader - the source of data to copy
      encoding - The encoding used in the character stream
      Throws:
      SQLException
    • transactionStateChanged

      public void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState)
      Description copied from interface: TransactionListener
      Signals that the transaction state changed.
      Specified by:
      transactionStateChanged in interface TransactionListener
      Parameters:
      transaction - FbTransaction that changed state