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 class org.firebirdsql.gds.ng.AbstractFbBlobAbstractFbBlob.BlobState
 - 
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)Creates a blob for output (writing to the database).JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId)Creates a blob for input (reading from the database).
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancelImpl()Internal implementation ofAbstractFbBlob.cancel().protected voidcloseImpl()Internal implementation ofAbstractFbBlob.close().protected intget(byte[] b, int off, int len, int minLen)Default implementation forAbstractFbBlob.get(byte[], int, int)andAbstractFbBlob.get(byte[], int, int, float).longgetBlobId()Returns the blob id.byte[]getBlobInfo(byte[] requestItems, int bufferLength)Request blob info.JnaDatabasegetDatabase()intgetHandle()Returns the blob handle identifier.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.voidput(byte[] b, int off, int len)Writes content ofbstarting atoffforlengthbytes to the blob.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, clearDeferredException, clearTransaction, close, createBlobLengthProcessor, detached, detaching, errorOccurred, get, get, getBlobInfo, getBlobParameterBuffer, getKnownBlobInfoItems, getMaximumSegmentSize, getState, isEndingTransaction, isEof, isOpen, length, putSegment, registerDeferredException, removeExceptionListener, resetEof, setEof, setState, throwAndClearDeferredException, transactionStateChanged, transferDeferredExceptionTo, warningReceived, withLock
 - 
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, get, get, getBlobInfo, getMaximumSegmentSize, isEof, isOpen, length, putSegment
 
- 
 
- 
- 
- 
Constructor Detail- 
JnaBlobpublic JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer) throws java.sql.SQLException Creates a blob for output (writing to the database).- Parameters:
- database- database
- transaction- transaction
- blobParameterBuffer- blob parameter buffer
- Throws:
- java.sql.SQLException
 
 - 
JnaBlobpublic JnaBlob(JnaDatabase database, JnaTransaction transaction, BlobParameterBuffer blobParameterBuffer, long blobId) throws java.sql.SQLException Creates a blob for input (reading from the database).- Parameters:
- database- database
- transaction- transaction
- blobParameterBuffer- blob parameter buffer
- blobId- blob id
- Throws:
- java.sql.SQLException
 
 
- 
 - 
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() Description copied from interface:FbBlobReturns the blob handle identifier.If the blob wasn't opened yet, this will return 0. If the blob was deferred opened (client-side only), this will return an invalid blob handle value (e.g.0xFFFF, though this value is potentially protocol/implementation specific).
 - 
getJnaHandlepublic final com.sun.jna.ptr.IntByReference getJnaHandle() 
 - 
getBlobIdpublic final long getBlobId() Description copied from interface:FbBlobReturns the blob id.For output blobs, this will return FbBlob.NO_BLOB_ID(0L) if the blob wasn't opened yet, or if the blob is deferred opened (client-side only). The valueFbBlob.NO_BLOB_IDis technically invalid, but Firebird will handle it as an empty blob (both for input and output).
 - 
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 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.
- See Also:
- FbBlob.get(byte[], int, int)
 
 - 
getprotected int get(byte[] b, int off, int len, int minLen) throws java.sql.SQLExceptionDescription copied from class:AbstractFbBlobDefault implementation forAbstractFbBlob.get(byte[], int, int)andAbstractFbBlob.get(byte[], int, int, float).- Specified by:
- getin class- AbstractFbBlob
- Parameters:
- b- target byte array
- off- offset to start
- len- number of bytes
- minLen- minimum number of bytes to fill (must be- 0 < minLen <= lenif- len != 0
- Returns:
- actual number of bytes read; is 0iflen == 0, will only be less thanminLenif end-of-blob is reached
- Throws:
- java.sql.SQLException- for database access errors, if- off < 0,- len < 0, or if- off + len > b.length, or- len != 0 && (minLen <= 0 || minLen > len)
 
 - 
putpublic void put(byte[] b, int off, int len) throws java.sql.SQLExceptionDescription copied from interface:FbBlobWrites content ofbstarting atoffforlengthbytes to the blob.Implementations must write all bytes to the blob, using multiple round-trips if necessary. If the implementation cannot perform writes without additional allocation, it should use at most DatabaseConnectionProperties.getBlobBufferSize()as an internal buffer. If the implementation can perform writes without additional allocation, it is recommended it performs reads using (at most)FbBlob.getMaximumSegmentSize().
 - 
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
 
 
- 
 
-