Package org.firebirdsql.jdbc
Class FBCachedBlob
- java.lang.Object
-
- org.firebirdsql.jdbc.FBCachedBlob
-
- All Implemented Interfaces:
java.sql.Blob
,FirebirdBlob
public final class FBCachedBlob extends java.lang.Object implements FirebirdBlob
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
Constructors Constructor Description FBCachedBlob(byte[] data)
Create an instance using the cached data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FirebirdBlob
detach()
Detach this blob.void
free()
java.io.InputStream
getBinaryStream()
java.io.InputStream
getBinaryStream(long pos, long length)
byte[]
getBytes(long pos, int length)
boolean
isSegmented()
Check if blob is segmented.long
length()
Get the length of the cached blob field.long
position(byte[] pattern, long start)
Find the first entry of the specified pattern.long
position(java.sql.Blob pattern, long start)
Find the first entry of the specified pattern.java.io.OutputStream
setBinaryStream(long pos)
Set the contents of blob as binary stream.int
setBytes(long pos, byte[] bytes)
Set contents of the blob.int
setBytes(long pos, byte[] bytes, int offset, int len)
Set the contents of blob.void
truncate(long length)
Truncate the blob to specified length.
-
-
-
Method Detail
-
detach
public FirebirdBlob detach() throws java.sql.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 a 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 interfaceFirebirdBlob
- Returns:
- instance of
FirebirdBlob
that is not under result set control. - Throws:
java.sql.SQLException
- if Blob cannot be detached.
-
isSegmented
public boolean isSegmented() throws java.sql.SQLException
Check if blob is segmented. If Blob is segmented, you cannot useFirebirdBlob.BlobInputStream.seek(int)
method.An instance of
FBCachedBlob
returnsfalse
always.- Specified by:
isSegmented
in interfaceFirebirdBlob
- Returns:
true
if this blob is segmented, otherwisefalse
- Throws:
java.sql.SQLException
-
length
public long length() throws java.sql.SQLException
Get the length of the cached blob field.- Specified by:
length
in interfacejava.sql.Blob
- Returns:
- length of the cached blob field or -1 if the field is null.
- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
- Specified by:
getBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
position
public long position(byte[] pattern, long start) throws java.sql.SQLException
Find the first entry of the specified pattern.- Specified by:
position
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, not yet implemented.
-
position
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
Find the first entry of the specified pattern.- Specified by:
position
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, not yet implemented.
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long pos, byte[] bytes) throws java.sql.SQLException
Set contents of the blob.- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, set methods are not relevant in cached state.
-
setBytes
public int setBytes(long pos, byte[] bytes, int offset, int len) throws java.sql.SQLException
Set the contents of blob.- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, set methods are not relevant in cached state.
-
setBinaryStream
public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
Set the contents of blob as binary stream.- Specified by:
setBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, set methods are not relevant in cached state.
-
truncate
public void truncate(long length) throws java.sql.SQLException
Truncate the blob to specified length.- Specified by:
truncate
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- always, truncate is not relevant in cached state.
-
free
public void free() throws java.sql.SQLException
- Specified by:
free
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
-