Class AbstractFbBlob
- java.lang.Object
- 
- org.firebirdsql.gds.ng.AbstractFbBlob
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable,- FbBlob,- DatabaseListener,- ExceptionListenable,- TransactionListener
 - Direct Known Subclasses:
- AbstractFbWireBlob,- JnaBlob
 
 public abstract class AbstractFbBlob extends java.lang.Object implements FbBlob, TransactionListener, DatabaseListener - Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.FbBlobFbBlob.SeekMode
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected ExceptionListenerDispatcherexceptionListenerDispatcher- 
Fields inherited from interface org.firebirdsql.gds.ng.FbBlobNO_BLOB_ID
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractFbBlob(FbDatabase database, FbTransaction transaction, BlobParameterBuffer blobParameterBuffer)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddExceptionListener(ExceptionListener listener)Adds an exception listener to this object.voidcancel()Cancels an output blob (which means its contents will be thrown away).protected abstract voidcancelImpl()Internal implementation ofcancel().protected voidcheckBlobClosed()protected voidcheckBlobOpen()protected voidcheckDatabaseAttached()protected voidcheckTransactionActive()protected voidclearDatabase()protected voidclearTransaction()voidclose()Closes the blob.protected abstract voidcloseImpl()Internal implementation ofclose().protected BlobLengthProcessorcreateBlobLengthProcessor()voiddetached(FbDatabase database)Called when thedatabaseconnection has been detachedvoiddetaching(FbDatabase database)Called before thedatabasewill be detached.<T> TgetBlobInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor)Request blob info.protected BlobParameterBuffergetBlobParameterBuffer()FbDatabasegetDatabase()intgetMaximumSegmentSize()The maximum segment size allowed by the protocol forFbBlob.getSegment(int)andFbBlob.putSegment(byte[]).java.lang.ObjectgetSynchronizationObject()Get synchronization object.protected FbTransactiongetTransaction()protected booleanisEndingTransaction()booleanisEof()booleanisOpen()longlength()Requests the blob length from the server.protected abstract voidreleaseResources()Release Java resources held.voidremoveExceptionListener(ExceptionListener listener)Removes an exception listener to this object.protected voidresetEof()Resets the eof state of the blob to false (not eof).protected voidsetEof()Marks this blob as EOF (End of file).protected voidsetOpen(boolean open)Sets the open state of the blob to the specified value.voidtransactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState)Signals that the transaction state changed.voidwarningReceived(FbDatabase database, java.sql.SQLWarning warning)Called when a warning was received for thedatabaseconnection.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.firebirdsql.gds.ng.FbBlobgetBlobId, getBlobInfo, getHandle, getSegment, isOutput, open, putSegment, seek
 
- 
 
- 
- 
- 
Field Detail- 
exceptionListenerDispatcherprotected final ExceptionListenerDispatcher exceptionListenerDispatcher 
 
- 
 - 
Constructor Detail- 
AbstractFbBlobprotected AbstractFbBlob(FbDatabase database, FbTransaction transaction, BlobParameterBuffer blobParameterBuffer) 
 
- 
 - 
Method Detail- 
isOpenpublic final boolean isOpen() 
 - 
isEofpublic final boolean isEof() 
 - 
setEofprotected final void setEof() Marks this blob as EOF (End of file).For an output blob this is a no-op (as those are never end of file, unless explicitly closed) 
 - 
resetEofprotected final void resetEof() Resets the eof state of the blob to false (not eof).This method should only be called by sub-classes of this class. 
 - 
setOpenprotected final void setOpen(boolean open) Sets the open state of the blob to the specified value.This method should only be called by sub-classes of this class. - Parameters:
- open- New value of open.
 
 - 
closepublic final void close() throws java.sql.SQLExceptionDescription copied from interface:FbBlobCloses the blob.Closing an already closed blob is a no-op. 
 - 
closeImplprotected abstract void closeImpl() throws java.sql.SQLExceptionInternal implementation ofclose(). The implementation does not need to check for attached database and active transaction, nor does it need to mark this blob as closed.- Throws:
- java.sql.SQLException
 
 - 
cancelpublic final void cancel() throws java.sql.SQLExceptionDescription copied from interface:FbBlobCancels an output blob (which means its contents will be thrown away).Calling cancel on an input blob will close it. Contrary to FbBlob.close(), calling cancel on an already closed (or cancelled) blob will throw anSQLException.
 - 
cancelImplprotected abstract void cancelImpl() throws java.sql.SQLExceptionInternal implementation ofcancel(). The implementation does not need to check for attached database and active transaction, nor does it need to mark this blob as closed.- Throws:
- java.sql.SQLException
 
 - 
releaseResourcesprotected abstract void releaseResources() Release Java resources held. This should not communicate with the Firebird server.
 - 
getSynchronizationObjectpublic final java.lang.Object getSynchronizationObject() Description copied from interface:FbBlobGet synchronization object.- Specified by:
- getSynchronizationObjectin interface- FbBlob
- Returns:
- object, cannot be null.
 
 - 
transactionStateChangedpublic void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListenerSignals that the transaction state changed.- Specified by:
- transactionStateChangedin interface- TransactionListener
- Parameters:
- transaction-- FbTransactionthat changed state
 
 - 
detachingpublic void detaching(FbDatabase database) Description copied from interface:DatabaseListenerCalled before thedatabasewill be detached.This event is intended for cleanup action, implementer should take care that no exceptions are thrown from this method. - Specified by:
- detachingin interface- DatabaseListener
- Parameters:
- database- The database object that is detaching
 
 - 
detachedpublic void detached(FbDatabase database) Description copied from interface:DatabaseListenerCalled when thedatabaseconnection has been detached- Specified by:
- detachedin interface- DatabaseListener
- Parameters:
- database- The database object that was detached
 
 - 
warningReceivedpublic void warningReceived(FbDatabase database, java.sql.SQLWarning warning) Description copied from interface:DatabaseListenerCalled when a warning was received for thedatabaseconnection.In implementation it is possible that some warnings are not sent to listeners on the database, but only to listeners on specific connection derived objects (like an FbStatementimplementation).- Specified by:
- warningReceivedin interface- DatabaseListener
- Parameters:
- database- Database receiving the warning
- warning- Warning
 
 - 
isEndingTransactionprotected final boolean isEndingTransaction() - Returns:
- trueif the transaction is committing, rolling back or preparing
 
 - 
checkTransactionActiveprotected final void checkTransactionActive() throws java.sql.SQLException- Throws:
- java.sql.SQLException- When no transaction is set, or the transaction state is not- TransactionState.ACTIVE
 
 - 
checkDatabaseAttachedprotected void checkDatabaseAttached() throws java.sql.SQLException- Throws:
- java.sql.SQLException- When no database is set, or the database is not attached
 
 - 
checkBlobOpenprotected void checkBlobOpen() throws java.sql.SQLException- Throws:
- java.sql.SQLException- When the blob is closed.
 
 - 
checkBlobClosedprotected void checkBlobClosed() throws java.sql.SQLException- Throws:
- java.sql.SQLException- When the blob is open.
 
 - 
getTransactionprotected FbTransaction getTransaction() 
 - 
clearTransactionprotected final void clearTransaction() 
 - 
getDatabasepublic FbDatabase getDatabase() - Specified by:
- getDatabasein interface- FbBlob
- Returns:
- The database connection that created this blob
 
 - 
getBlobInfopublic <T> T getBlobInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws java.sql.SQLExceptionDescription copied from interface:FbBlobRequest blob info.- Specified by:
- getBlobInfoin interface- FbBlob
- Parameters:
- requestItems- Array of info items to request
- bufferLength- Response buffer length to use
- infoProcessor- Implementation of- InfoProcessorto transform the info response
- Returns:
- Transformed info response of type T
- Throws:
- java.sql.SQLException- For errors retrieving or transforming the response.
 
 - 
lengthpublic long length() throws java.sql.SQLExceptionDescription copied from interface:FbBlobRequests the blob length from the server.
 - 
addExceptionListenerpublic final void addExceptionListener(ExceptionListener listener) Description copied from interface:ExceptionListenableAdds an exception listener to this object.Implementations use WeakReference.- Specified by:
- addExceptionListenerin interface- ExceptionListenable
- Parameters:
- listener- Listener to register
 
 - 
removeExceptionListenerpublic final void removeExceptionListener(ExceptionListener listener) Description copied from interface:ExceptionListenableRemoves an exception listener to this object.- Specified by:
- removeExceptionListenerin interface- ExceptionListenable
- Parameters:
- listener- Listener to remove
 
 - 
clearDatabaseprotected final void clearDatabase() 
 - 
getBlobParameterBufferprotected BlobParameterBuffer getBlobParameterBuffer() - Returns:
- The blob parameter buffer of this blob.
 
 - 
createBlobLengthProcessorprotected BlobLengthProcessor createBlobLengthProcessor() - Returns:
- New instance of BlobLengthProcessor(or subclass) for this blob.
 
 - 
getMaximumSegmentSizepublic int getMaximumSegmentSize() Description copied from interface:FbBlobThe maximum segment size allowed by the protocol forFbBlob.getSegment(int)andFbBlob.putSegment(byte[]).This value is not the segment size (optionally) defined for the column. - Specified by:
- getMaximumSegmentSizein interface- FbBlob
- Returns:
- The maximum segment size allowed for get or put.
 
 
- 
 
-