public interface FbBlob extends ExceptionListenable, java.lang.AutoCloseable
All methods defined in this interface are required to notify all SQLException
thrown from the methods
defined in this interface.
Modifier and Type | Interface and Description |
---|---|
static class |
FbBlob.SeekMode
Seek mode for
seek(int, org.firebirdsql.gds.ng.FbBlob.SeekMode) . |
Modifier and Type | Field and Description |
---|---|
static long |
NO_BLOB_ID |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels an output blob (which means its contents will be thrown away).
|
void |
close()
Closes the blob.
|
long |
getBlobId() |
byte[] |
getBlobInfo(byte[] requestItems,
int bufferLength)
Request blob info.
|
<T> T |
getBlobInfo(byte[] requestItems,
int bufferLength,
InfoProcessor<T> infoProcessor)
Request blob info.
|
FbDatabase |
getDatabase() |
int |
getHandle() |
int |
getMaximumSegmentSize()
The maximum segment size allowed by the protocol for
getSegment(int) and putSegment(byte[]) . |
byte[] |
getSegment(int sizeRequested)
Gets a segment of blob data.
|
java.lang.Object |
getSynchronizationObject()
Get synchronization object.
|
boolean |
isEof() |
boolean |
isOpen() |
boolean |
isOutput() |
long |
length()
Requests the blob length from the server.
|
void |
open()
Opens an existing input blob, or creates an output blob.
|
void |
putSegment(byte[] segment)
Writes a segment of blob data.
|
void |
seek(int offset,
FbBlob.SeekMode seekMode)
Performs a seek on a blob with the specified
seekMode and offset . |
addExceptionListener, removeExceptionListener
static final long NO_BLOB_ID
long getBlobId()
int getHandle()
FbDatabase getDatabase()
void open() throws java.sql.SQLException
java.sql.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 occurredboolean isOpen()
true
if this blob is currently open.boolean isEof()
true
if this blob has reached the end or has been closed, always true
for an
open output blob.void close() throws java.sql.SQLException
Closing an already closed blob is a no-op.
close
in interface java.lang.AutoCloseable
java.sql.SQLException
- If the transaction is not active, or a database connection error occurredvoid cancel() throws java.sql.SQLException
Calling cancel on an input blob will close it. Contrary to close()
, calling cancel on an
already closed (or cancelled) blob will throw an SQLException
.
java.sql.SQLException
- If the blob has already been closed, the transaction is not active, or a database connection error
occurred.boolean isOutput()
true
if this is an output blob (write only), false
if this is an
input blob (read only)java.lang.Object getSynchronizationObject()
null
.byte[] getSegment(int sizeRequested) throws java.sql.SQLException
When sizeRequested
exceeds getMaximumSegmentSize()
it is silently reduced to the maximum
segment size.
sizeRequested
- Requested segment size (> 0).java.sql.SQLException
- If this is an output blob, the blob is closed, the transaction is not active, or a database connection
error occurred.void putSegment(byte[] segment) throws java.sql.SQLException
Implementation must handle segment length exceeding getMaximumSegmentSize()
by batching. TODO: reconsider and let caller handle that?
Passing a section that is length 0 will throw an SQLException
.
segment
- Segment to writejava.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.void seek(int offset, FbBlob.SeekMode seekMode) throws java.sql.SQLException
seekMode
and offset
.
Firebird only supports seek on stream blobs.
offset
- Offset of the seek, effect depends on value of seekMode
seekMode
- Value of FbBlob.SeekMode
java.sql.SQLException
- If the blob is closed, the transaction is not active, or a database error occurred.int getMaximumSegmentSize()
getSegment(int)
and putSegment(byte[])
.
This value is not the segment size (optionally) defined for the column.
<T> T getBlobInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws java.sql.SQLException
requestItems
- Array of info items to requestbufferLength
- Response buffer length to useinfoProcessor
- Implementation of InfoProcessor
to transform
the info responsejava.sql.SQLException
- For errors retrieving or transforming the response.long length() throws java.sql.SQLException
java.sql.SQLException
- For Errors retrieving the length, or if the blob is not associated with a blob id, or the database is not
attached.byte[] getBlobInfo(byte[] requestItems, int bufferLength) throws java.sql.SQLException
requestItems
- Array of info items to requestbufferLength
- Response buffer length to usejava.sql.SQLException
Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.