Package org.firebirdsql.jdbc
Class FBBlob
java.lang.Object
org.firebirdsql.jdbc.FBBlob
- All Implemented Interfaces:
Blob,TransactionListener,FirebirdBlob,Synchronizable
Firebird implementation of
Blob.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.firebirdsql.jdbc.FirebirdBlob
FirebirdBlob.BlobInputStream, FirebirdBlob.BlobOutputStream -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate new Blob instance.Create instance of this class to access existing Blob.FBBlob(GDSHelper c, long blob_id, FBObjectListener.BlobListener blobListener) Create instance of this class to access existing Blob.FBBlob(GDSHelper c, FBObjectListener.BlobListener blobListener) Create new Blob instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyBytes(byte[] bytes, int pos, int len) voidcopyCharacterStream(Reader reader, long length, Encoding encoding) Copy data from a character stream into this Blob.voidcopyCharacterStream(Reader reader, Encoding encoding) Copy data from a character stream into this Blob.voidcopyStream(InputStream inputStream) Copy the contents of anInputStreaminto this Blob.voidcopyStream(InputStream inputStream, long length) Copy the contents of anInputStreaminto this Blob.detach()Detach this blob.voidfree()getBinaryStream(long pos, long length) longGet the identifier for thisBlobbyte[]getBytes(long pos, int length) byte[]getInfo(byte[] items, int buffer_length) Get information about this Blob.final ObjectGet synchronization object.booleanCheck if blob is segmented.longlength()longposition(byte[] pattern, long start) longsetBinaryStream(long pos) intsetBytes(long pos, byte[] bytes) intsetBytes(long pos, byte[] bytes, int offset, int len) voidtransactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Signals that the transaction state changed.voidtruncate(long len)
-
Field Details
-
SEGMENTED
public static final boolean SEGMENTED- See Also:
-
-
Constructor Details
-
FBBlob
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 blobblobListener- Blob listener instance
-
FBBlob
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
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
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
Description copied from interface:SynchronizableGet synchronization object.- Specified by:
getSynchronizationObjectin interfaceSynchronizable- Returns:
- object, cannot be
null.
-
free
- Specified by:
freein interfaceBlob- Throws:
SQLException
-
getBinaryStream
- Specified by:
getBinaryStreamin interfaceBlob- Throws:
SQLException
-
getInfo
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
- Specified by:
lengthin interfaceBlob- Throws:
SQLException
-
isSegmented
Description copied from interface:FirebirdBlobCheck if blob is segmented. If Blob is segmented, you cannot useFirebirdBlob.BlobInputStream.seek(int)method.- Specified by:
isSegmentedin interfaceFirebirdBlob- Returns:
trueif this blob is segmented, otherwisefalse- Throws:
SQLException
-
detach
Description copied from interface:FirebirdBlobDetach 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:
detachin interfaceFirebirdBlob- Returns:
- instance of
FirebirdBlobthat is not under result set control. - Throws:
SQLException- if Blob cannot be detached.
-
getBytes
- Specified by:
getBytesin interfaceBlob- Throws:
SQLException
-
getBinaryStream
- Specified by:
getBinaryStreamin interfaceBlob- Throws:
SQLException
-
position
- Specified by:
positionin interfaceBlob- Throws:
SQLException
-
position
- Specified by:
positionin interfaceBlob- Throws:
SQLException
-
truncate
- Specified by:
truncatein interfaceBlob- Throws:
SQLException
-
setBytes
- Specified by:
setBytesin interfaceBlob- Throws:
SQLException
-
setBytes
- Specified by:
setBytesin interfaceBlob- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStreamin interfaceBlob- Throws:
SQLException
-
getBlobId
Get the identifier for thisBlob- Returns:
- This
Blob's identifier - Throws:
SQLException- if a database access error occurs
-
copyBytes
- Throws:
SQLException
-
getGdsHelper
-
copyStream
Copy the contents of anInputStreaminto this Blob.Calling with length
-1is equivalent to callingcopyStream(InputStream), and will copy the whole stream.- Parameters:
inputStream- the stream from which data will be copiedlength- The maximum number of bytes to read from the InputStream,-1to read whole stream- Throws:
SQLException- if a database access error occurs
-
copyStream
Copy the contents of anInputStreaminto this Blob. Unlike thecopyStream(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
Copy data from a character stream into this Blob.Calling with length
-1is equivalent to callingcopyCharacterStream(Reader, Encoding).- Parameters:
reader- the source of data to copylength- The maximum number of bytes to copy, or-1to read the whole streamencoding- The encoding used in the character stream- Throws:
SQLException
-
copyCharacterStream
Copy data from a character stream into this Blob. Unlike thecopyCharacterStream(Reader, long, Encoding))} method, this one copies bytes until the EOF is reached.- Parameters:
reader- the source of data to copyencoding- The encoding used in the character stream- Throws:
SQLException
-
transactionStateChanged
public void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListenerSignals that the transaction state changed.- Specified by:
transactionStateChangedin interfaceTransactionListener- Parameters:
transaction-FbTransactionthat changed state
-