## org.firebirdsql.jdbc
Class FBCachedBlob

    java.lang.Object
      org.firebirdsql.jdbc.FBCachedBlob

All Implemented Interfaces:
  Blob, FirebirdBlob, Synchronizable

    public class FBCachedBlob

extends Object
implements FirebirdBlob, Synchronizable

This class represents a cached blob field.

Nested Class Summary

Nested classes/interfaces inherited from interface org.firebirdsql.jdbc.FirebirdBlob
`FirebirdBlob.BlobInputStream, FirebirdBlob.BlobOutputStream`

Constructor Summary
`FBCachedBlob(byte[] data)` Create an instance using the cached data.

Method Summary
`FirebirdBlob` `detach()` Detach this blob.
`void` `free()`
`InputStream` `getBinaryStream()` Get contents of blob as binary stream.
`InputStream` `getBinaryStream(long pos, long length)`
`byte[]` `getBytes(long pos, int length)` Get part of the blob field.
`Object` `getSynchronizationObject()` Get synchronization object.
`boolean` `isSegmented()` Check if blob is segmented.
`long` `length()` Get the length of the cached blob field.
`long` `position(Blob pattern, long start)` Find the first entry of the specified pattern.
`long` `position(byte[] pattern, long start)` Find the first entry of the specified pattern.
`OutputStream` `setBinaryStream(long pos)` Set the contents of blob as binary stream.
`int` `setBytes(long l, byte[] abyte0)` Set contents of the blob.
`int` `setBytes(long l, byte[] abyte0, int i, int j)` Set the contents of blob.
`void` `truncate(long length)` Truncate the blob to specified length.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FBCachedBlob

    public FBCachedBlob(byte[] data)

  Create an instance using the cached data.

  Parameters:
    `data` - array of bytes containing the cached data.

Method Detail

### 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.

### 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`

### length

    public long length()
                throws SQLException

  Get the length of the cached blob field.

  Specified by:
    `length` in interface `Blob`
  Returns:
    length of the cached blob field or -1 if the field is null.
  Throws:
    `SQLException`

### getBytes

    public byte[] getBytes(long pos,
                           int length)
                    throws SQLException

  Get part of the blob field.

  Specified by:
    `getBytes` in interface `Blob`
  Parameters:
    `pos` - starting position to copy.
    `length` - amount of bytes to copy.
  Throws:
    `SQLException`

### position

    public long position(byte[] pattern,
                         long start)
                  throws SQLException

  Find the first entry of the specified pattern.

  Specified by:
    `position` in interface `Blob`
  Throws:
    `SQLException` - always, not yet implemented.

### position

    public long position(Blob pattern,
                         long start)
                  throws SQLException

  Find the first entry of the specified pattern.

  Specified by:
    `position` in interface `Blob`
  Throws:
    `SQLException` - always, not yet implemented.

### getBinaryStream

    public InputStream getBinaryStream()
                                throws SQLException

  Get contents of blob as binary stream.

  Specified by:
    `getBinaryStream` in interface `Blob`
  Throws:
    `SQLException`

### setBytes

    public int setBytes(long l,
                        byte[] abyte0)
                 throws SQLException

  Set contents of the blob.

  Specified by:
    `setBytes` in interface `Blob`
  Throws:
    `SQLException` - always, set methods are not relevant in cached state.

### setBytes

    public int setBytes(long l,
                        byte[] abyte0,
                        int i,
                        int j)
                 throws SQLException

  Set the contents of blob.

  Specified by:
    `setBytes` in interface `Blob`
  Throws:
    `SQLException` - always, set methods are not relevant in cached state.

### setBinaryStream

    public OutputStream setBinaryStream(long pos)
                                 throws SQLException

  Set the contents of blob as binary stream.

  Specified by:
    `setBinaryStream` in interface `Blob`
  Specified by:
    `setBinaryStream` in interface `FirebirdBlob`
  Parameters:
    `pos` - the position in the `BLOB` value at which to start writing; currently only position 0 is supported.
  Returns:
    a `java.io.OutputStream` object to which data can be written
  Throws:
    `SQLException` - always, set methods are not relevant in cached state.

### truncate

    public void truncate(long length)
                  throws SQLException

  Truncate the blob to specified length.

  Specified by:
    `truncate` in interface `Blob`
  Throws:
    `SQLException` - always, truncate is not relevant in cached state.

### getSynchronizationObject

    public Object getSynchronizationObject()
                                    throws SQLException

  Description copied from interface: `Synchronizable`
  Get synchronization object.

  Specified by:
    `getSynchronizationObject` in interface `Synchronizable`
  Returns:
    object, cannot be `null`.
  Throws:
    `SQLException` - if something went wrong.

### 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`

Copyright © 2001-2010. All Rights Reserved.