java.lang.Object
org.firebirdsql.jdbc.FBBlob
- All Implemented Interfaces:
Blob
,TransactionListener
,FirebirdBlob
Firebird implementation of
Blob
.
This class is internal API of Jaybird. Future versions may radically change, move, or make inaccessible this type.
For the public API, refer to the Blob
and FirebirdBlob
interfaces.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Standard configuration for blobs.Nested classes/interfaces inherited from interface org.firebirdsql.jdbc.FirebirdBlob
FirebirdBlob.BlobInputStream, FirebirdBlob.BlobOutputStream
-
Constructor Summary
ConstructorsConstructorDescriptionFBBlob
(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener, FBBlob.Config config) Create instance of this class to access existing Blob.FBBlob
(GDSHelper c, FBObjectListener.BlobListener blobListener, FBBlob.Config config) Create new Blob instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyBytes
(byte[] bytes, int pos, int len) void
copyCharacterStream
(Reader reader) Copy data from a character stream into this Blob.void
copyCharacterStream
(Reader reader, long length) Copy data from a character stream into this Blob.void
copyCharacterStream
(Reader reader, long length, Encoding encoding) Copy data from a character stream into this Blob.void
copyCharacterStream
(Reader reader, Encoding encoding) Copy data from a character stream into this Blob.void
copyStream
(InputStream inputStream) Copy the contents of anInputStream
into this Blob.void
copyStream
(InputStream inputStream, long length) Copy the contents of anInputStream
into this Blob.static FBBlob.Config
createConfig
(int subType, boolean useStreamBlob, int blobBufferSize, DatatypeCoder datatypeCoder) Create a blob configuration.static FBBlob.Config
createConfig
(int subType, DatabaseConnectionProperties connectionProperties, DatatypeCoder datatypeCoder) Creates a blob configuration from a subtype and connection properties and datatype coder.static FBBlob.Config
createConfig
(FieldDescriptor fieldDescriptor, DatabaseConnectionProperties connectionProperties) Creates a blob configuration from a field descriptor and connection properties.detach()
Detach this blob.void
free()
getBinaryStream
(long pos, long length) long
Get the identifier for thisBlob
byte[]
getBytes()
Gets the byte content of this blob as a byte array.byte[]
getBytes
(long pos, int length) byte[]
getInfo
(byte[] items, int bufferLength) Get information about this Blob.boolean
Check if blob is segmented.long
length()
long
position
(byte[] pattern, long start) long
setBinaryStream
(long pos) int
setBytes
(long pos, byte[] bytes) int
setBytes
(long pos, byte[] bytes, int offset, int len) void
transactionStateChanged
(FbTransaction transaction, TransactionState newState, TransactionState previousState) Signals that the transaction state changed.void
truncate
(long len)
-
Constructor Details
-
FBBlob
Create new Blob instance. This constructor creates a new fresh Blob, only writing to the Blob is allowed.- Parameters:
c
- connection that will be used to write data to blobblobListener
- Blob listener instanceconfig
- blob configuration (cannot benull
)- Since:
- 5
-
FBBlob
public FBBlob(GDSHelper c, long blobId, FBObjectListener.BlobListener blobListener, FBBlob.Config config) Create instance of this class to access existing Blob.- Parameters:
c
- connection that will be used to access Blob.blobId
- ID of the Blob.blobListener
- blob listener instanceconfig
- blob configuration (cannot benull
)- Since:
- 5
-
-
Method Details
-
free
- Specified by:
free
in interfaceBlob
- Throws:
SQLException
-
getBinaryStream
- Specified by:
getBinaryStream
in interfaceBlob
- Throws:
SQLException
-
getInfo
Get information about this Blob. This method should be considered as temporary because it provides access to low-level API. More information on how to use the API can be found in "API Guide".- Parameters:
items
- items in which we are interestedbufferLength
- buffer where information will be stored- Returns:
- array of bytes containing information about this Blob
- Throws:
SQLException
- if something went wrong
-
length
- Specified by:
length
in interfaceBlob
- Throws:
SQLException
-
isSegmented
Description copied from interface:FirebirdBlob
Check if blob is segmented. If Blob is segmented, you cannot useFirebirdBlob.BlobInputStream.seek(int)
method.- Specified by:
isSegmented
in interfaceFirebirdBlob
- Returns:
true
if this blob is segmented, otherwisefalse
- Throws:
SQLException
-
detach
Description copied from interface:FirebirdBlob
Detach this blob. This method creates new instance of the same blob database object that is not under result set control. When result set is closed, all associated resources are also released, including open blob streams. This method creates a new instance of blob object with the same blob ID that can be used even when result set is closed.Note, detached blob will not remember the stream position of this object. This means that you cannot start reading data from the blob, then detach it, and then continue reading. Reading from detached blob will begin at the blob start.
- Specified by:
detach
in interfaceFirebirdBlob
- Returns:
- instance of
FirebirdBlob
that is not under result set control. - Throws:
SQLException
- if Blob cannot be detached.
-
getBytes
- Specified by:
getBytes
in interfaceBlob
- Throws:
SQLException
-
getBytes
Description copied from interface:FirebirdBlob
Gets the byte content of this blob as a byte array.- Specified by:
getBytes
in interfaceFirebirdBlob
- Returns:
- byte array with blob content (may return
null
for certain cached blobs) - Throws:
SQLException
- for database access errors, or if the blob size exceeds the maximum safe array size (i.e.Integer.MAX_VALUE
- 8)
-
getBinaryStream
- Specified by:
getBinaryStream
in interfaceBlob
- Throws:
SQLException
-
position
- Specified by:
position
in interfaceBlob
- Throws:
SQLException
-
position
- Specified by:
position
in interfaceBlob
- Throws:
SQLException
-
truncate
- Specified by:
truncate
in interfaceBlob
- Throws:
SQLException
-
setBytes
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
-
setBytes
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStream
in interfaceBlob
- Throws:
SQLException
-
getBlobId
Get the identifier for thisBlob
- Returns:
- This
Blob
's identifier - Throws:
SQLException
- if a database access error occurs
-
copyBytes
- Throws:
SQLException
-
copyStream
Copy the contents of anInputStream
into this Blob.Calling with length
-1
is equivalent to callingcopyStream(InputStream)
, and will copy the whole stream.- Parameters:
inputStream
- the stream from which data will be copiedlength
- The maximum number of bytes to read from the InputStream,-1
to read whole stream- Throws:
SQLException
- if a database access error occurs
-
copyStream
Copy the contents of anInputStream
into this Blob. Unlike thecopyStream(InputStream, long)
method, this one copies bytes until the EOF is reached.- Parameters:
inputStream
- the stream from which data will be copied- Throws:
SQLException
- if a database access error occurs
-
copyCharacterStream
Copy data from a character stream into this Blob.Calling with length
-1
is equivalent to callingcopyCharacterStream(Reader, Encoding)
.- Parameters:
reader
- the source of data to copylength
- The maximum number of bytes to copy, or-1
to read the whole streamencoding
- The encoding used in the character stream- Throws:
SQLException
- See Also:
-
copyCharacterStream
Copy data from a character stream into this Blob. This method uses the encoding from the blob config (field character set for subtype TEXT, if known, otherwise connection character set).Calling with length
-1
is equivalent to callingcopyCharacterStream(Reader)
.- Parameters:
reader
- the source of data to copylength
- The maximum number of bytes to copy, or-1
to read the whole stream- Throws:
SQLException
- Since:
- 5
-
copyCharacterStream
Copy data from a character stream into this Blob. Unlike thecopyCharacterStream(Reader, long, Encoding)
method, this one copies bytes until the EOF is reached.- Parameters:
reader
- the source of data to copyencoding
- The encoding used in the character stream- Throws:
SQLException
- See Also:
-
copyCharacterStream
Copy data from a character stream into this Blob. Unlike thecopyCharacterStream(Reader, long)
method, this one copies bytes until the EOF is reached. This method uses the encoding from the blob config (field character set for subtype TEXT, if known, otherwise connection character set).- Parameters:
reader
- the source of data to copy- Throws:
SQLException
- Since:
- 5
-
transactionStateChanged
public void transactionStateChanged(FbTransaction transaction, TransactionState newState, TransactionState previousState) Description copied from interface:TransactionListener
Signals that the transaction state changed.- Specified by:
transactionStateChanged
in interfaceTransactionListener
- Parameters:
transaction
-FbTransaction
that changed state
-
createConfig
public static FBBlob.Config createConfig(FieldDescriptor fieldDescriptor, DatabaseConnectionProperties connectionProperties) Creates a blob configuration from a field descriptor and connection properties.- Parameters:
fieldDescriptor
- field descriptorconnectionProperties
- connection properties- Returns:
- field based blob configuration
- Since:
- 5
-
createConfig
public static FBBlob.Config createConfig(int subType, DatabaseConnectionProperties connectionProperties, DatatypeCoder datatypeCoder) Creates a blob configuration from a subtype and connection properties and datatype coder.- Parameters:
subType
- blob subtype (e.g.ISCConstants.BLOB_SUB_TYPE_BINARY
orISCConstants.BLOB_SUB_TYPE_TEXT
)connectionProperties
- connection propertiesdatatypeCoder
- data type coder for the connection character set- Returns:
- field based blob configuration
- Since:
- 5
-
createConfig
public static FBBlob.Config createConfig(int subType, boolean useStreamBlob, int blobBufferSize, DatatypeCoder datatypeCoder) Create a blob configuration.- Parameters:
subType
- blob subtype (e.g.ISCConstants.BLOB_SUB_TYPE_BINARY
orISCConstants.BLOB_SUB_TYPE_TEXT
)useStreamBlob
-true
use stream blob,false
use segmented blobblobBufferSize
- blob buffer sizedatatypeCoder
- data type coder for the connection character set- Returns:
- generic blob configuration
- Since:
- 5
-