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:
- java.lang.AutoCloseable,- FbBlob,- DatabaseListener,- ExceptionListenable,- TransactionListener
 
 public class JnaBlob extends AbstractFbBlob implements FbBlob, DatabaseListener Implementation ofFbBlobfor native client access.- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.FbBlobFbBlob.SeekMode
 
- 
 - 
Field Summary- 
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbBlobexceptionListenerDispatcher
 - 
Fields inherited from interface org.firebirdsql.gds.ng.FbBlobNO_BLOB_ID
 
- 
 - 
Constructor SummaryConstructors Constructor Description JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer)JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancelImpl()Internal implementation ofAbstractFbBlob.cancel().protected voidcloseImpl()Internal implementation ofAbstractFbBlob.close().longgetBlobId()byte[]getBlobInfo(byte[] requestItems, int bufferLength)Request blob info.JnaDatabasegetDatabase()intgetHandle()com.sun.jna.ptr.IntByReferencegetJnaHandle()byte[]getSegment(int sizeRequested)Gets a segment of blob data.JnaTransactiongetTransaction()booleanisOutput()voidopen()Opens an existing input blob, or creates an output blob.voidputSegment(byte[] segment)Writes a segment of blob data.protected voidreleaseResources()Release 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.AbstractFbBlobaddExceptionListener, cancel, checkBlobClosed, checkBlobOpen, checkDatabaseAttached, checkTransactionActive, clearDatabase, clearTransaction, close, createBlobLengthProcessor, detached, detaching, getBlobInfo, getBlobParameterBuffer, getMaximumSegmentSize, getSynchronizationObject, isEndingTransaction, isEof, isOpen, length, removeExceptionListener, resetEof, setEof, setOpen, transactionStateChanged, warningReceived
 - 
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.listeners.DatabaseListenerdetached, detaching, warningReceived
 - 
Methods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenableaddExceptionListener, removeExceptionListener
 - 
Methods inherited from interface org.firebirdsql.gds.ng.FbBlobcancel, close, getBlobInfo, getMaximumSegmentSize, getSynchronizationObject, isEof, isOpen, length
 
- 
 
- 
- 
- 
Constructor Detail- 
JnaBlobpublic JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer) 
 - 
JnaBlobpublic JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) 
 
- 
 - 
Method Detail- 
getDatabasepublic JnaDatabase getDatabase() - Specified by:
- getDatabasein interface- FbBlob
- Overrides:
- getDatabasein class- AbstractFbBlob
- Returns:
- The database connection that created this blob
 
 - 
getTransactionpublic JnaTransaction getTransaction() - Overrides:
- getTransactionin class- AbstractFbBlob
 
 - 
getHandlepublic int getHandle() 
 - 
getJnaHandlepublic final com.sun.jna.ptr.IntByReference getJnaHandle() 
 - 
getBlobIdpublic final long getBlobId() 
 - 
openpublic void open() throws java.sql.SQLExceptionDescription copied from interface:FbBlobOpens an existing input blob, or creates an output blob.
 - 
isOutputpublic final boolean isOutput() 
 - 
getSegmentpublic byte[] getSegment(int sizeRequested) throws java.sql.SQLExceptionDescription 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 interface- FbBlob
- Parameters:
- sizeRequested- Requested segment size (> 0).
- Returns:
- Retrieved segment (size may be less than requested)
- Throws:
- java.sql.SQLException- If this is an output blob, the blob is closed, the transaction is not active, or a database connection error occurred.
 
 - 
putSegmentpublic void putSegment(byte[] segment) throws java.sql.SQLExceptionDescription 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 interface- FbBlob
- Parameters:
- segment- Segment to write
- Throws:
- java.sql.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.
 
 - 
seekpublic void seek(int offset, FbBlob.SeekMode seekMode) throws java.sql.SQLExceptionDescription copied from interface:FbBlobPerforms a seek on a blob with the specifiedseekModeandoffset.Firebird only supports seek on stream blobs. - Specified by:
- seekin interface- FbBlob
- Parameters:
- offset- Offset of the seek, effect depends on value of- seekMode
- seekMode- Value of- FbBlob.SeekMode
- Throws:
- java.sql.SQLException- If the blob is closed, the transaction is not active, or a database error occurred.
 
 - 
getBlobInfopublic byte[] getBlobInfo(byte[] requestItems, int bufferLength) 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
- Returns:
- Response buffer
- Throws:
- java.sql.SQLException
 
 - 
closeImplprotected void closeImpl() throws java.sql.SQLExceptionDescription 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 class- AbstractFbBlob
- Throws:
- java.sql.SQLException
 
 - 
cancelImplprotected void cancelImpl() throws java.sql.SQLExceptionDescription 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 class- AbstractFbBlob
- Throws:
- java.sql.SQLException
 
 - 
releaseResourcesprotected void releaseResources() Description copied from class:AbstractFbBlobRelease Java resources held. This should not communicate with the Firebird server.- Specified by:
- releaseResourcesin class- AbstractFbBlob
 
 
- 
 
-