Package org.firebirdsql.gds.ng.jna
Class JnaBlob
java.lang.Object
org.firebirdsql.gds.ng.AbstractFbBlob
org.firebirdsql.gds.ng.jna.JnaBlob
- All Implemented Interfaces:
AutoCloseable,FbBlob,DatabaseListener,ExceptionListenable,TransactionListener
Implementation of
FbBlob for native client access.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.FbBlob
FbBlob.SeekMode -
Field Summary
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbBlob
exceptionListenerDispatcherFields inherited from interface org.firebirdsql.gds.ng.FbBlob
NO_BLOB_ID -
Constructor Summary
ConstructorsConstructorDescriptionJnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer) JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidInternal implementation ofAbstractFbBlob.cancel().protected voidInternal implementation ofAbstractFbBlob.close().final longbyte[]getBlobInfo(byte[] requestItems, int bufferLength) Request blob info.intfinal com.sun.jna.ptr.IntByReferencebyte[]getSegment(int sizeRequested) Gets a segment of blob data.final booleanisOutput()voidopen()Opens an existing input blob, or creates an output blob.voidputSegment(byte[] segment) Writes a segment of blob data.protected voidRelease Java resources held.voidseek(int offset, FbBlob.SeekMode seekMode) Performs a seek on a blob with the specifiedseekModeandoffset.Methods inherited from class org.firebirdsql.gds.ng.AbstractFbBlob
addExceptionListener, cancel, checkBlobClosed, checkBlobOpen, checkDatabaseAttached, checkTransactionActive, clearDatabase, clearTransaction, close, createBlobLengthProcessor, detached, detaching, getBlobInfo, getBlobParameterBuffer, getMaximumSegmentSize, getSynchronizationObject, isEndingTransaction, isEof, isOpen, length, removeExceptionListener, resetEof, setEof, setOpen, transactionStateChanged, warningReceivedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.firebirdsql.gds.ng.listeners.DatabaseListener
detached, detaching, warningReceivedMethods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable
addExceptionListener, removeExceptionListenerMethods inherited from interface org.firebirdsql.gds.ng.FbBlob
cancel, close, getBlobInfo, getMaximumSegmentSize, getSynchronizationObject, isEof, isOpen, length
-
Constructor Details
-
JnaBlob
public JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer) -
JnaBlob
public JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)
-
-
Method Details
-
getDatabase
- Specified by:
getDatabasein interfaceFbBlob- Overrides:
getDatabasein classAbstractFbBlob- Returns:
- The database connection that created this blob
-
getTransaction
- Overrides:
getTransactionin classAbstractFbBlob
-
getHandle
public int getHandle() -
getJnaHandle
public final com.sun.jna.ptr.IntByReference getJnaHandle() -
getBlobId
public final long getBlobId() -
open
Description copied from interface:FbBlobOpens an existing input blob, or creates an output blob.- Specified by:
openin interfaceFbBlob- Throws:
SQLException- If the blob is already open, this is a (closed) output blob and it already has a blobId, the transaction is not active, or a database connection error occurred
-
isOutput
public final boolean isOutput() -
getSegment
Description copied from interface:FbBlobGets a segment of blob data.When
TODO: Consider allowing this and have the implementation handle longer segments by sending multiple (batched?) requests.sizeRequestedexceedsFbBlob.getMaximumSegmentSize()it is silently reduced to the maximum segment size.- Specified by:
getSegmentin interfaceFbBlob- Parameters:
sizeRequested- Requested segment size (> 0).- Returns:
- Retrieved segment (size may be less than requested)
- Throws:
SQLException- If this is an output blob, the blob is closed, the transaction is not active, or a database connection error occurred.
-
putSegment
Description copied from interface:FbBlobWrites a segment of blob data.Implementation must handle segment length exceeding
FbBlob.getMaximumSegmentSize()by batching. TODO: reconsider and let caller handle that?Passing a section that is length 0 will throw an
SQLException.- Specified by:
putSegmentin interfaceFbBlob- Parameters:
segment- Segment to write- Throws:
SQLException- If this is an input blob, the blob is closed, the transaction is not active, the segment is length 0 or longer than the maximum segment size, or a database connection error occurred.
-
seek
Description copied from interface:FbBlobPerforms a seek on a blob with the specifiedseekModeandoffset.Firebird only supports seek on stream blobs.
- Specified by:
seekin interfaceFbBlob- Parameters:
offset- Offset of the seek, effect depends on value ofseekModeseekMode- Value ofFbBlob.SeekMode- Throws:
SQLException- If the blob is closed, the transaction is not active, or a database error occurred.
-
getBlobInfo
Description copied from interface:FbBlobRequest blob info.- Specified by:
getBlobInfoin interfaceFbBlob- Parameters:
requestItems- Array of info items to requestbufferLength- Response buffer length to use- Returns:
- Response buffer
- Throws:
SQLException
-
closeImpl
Description copied from class:AbstractFbBlobInternal implementation ofAbstractFbBlob.close(). The implementation does not need to check for attached database and active transaction, nor does it need to mark this blob as closed.- Specified by:
closeImplin classAbstractFbBlob- Throws:
SQLException
-
cancelImpl
Description copied from class:AbstractFbBlobInternal implementation ofAbstractFbBlob.cancel(). The implementation does not need to check for attached database and active transaction, nor does it need to mark this blob as closed.- Specified by:
cancelImplin classAbstractFbBlob- Throws:
SQLException
-
releaseResources
protected void releaseResources()Description copied from class:AbstractFbBlobRelease Java resources held. This should not communicate with the Firebird server.- Specified by:
releaseResourcesin classAbstractFbBlob
-