Note
In the case that the data is large, it is represented as a stream. This stream is returned to the user in the getBinaryStream() method. This means that we have limited control over the state of the stream, since the user can read bytes from it at any time. Thus all methods here reset the stream to the beginning before doing any work.
Caveat
The methods may not behave correctly if a user sets up multiple threads and sucks data from the stream (returned from getBinaryStream()) at the same time as calling the Blob methods.
Supports
| Modifier and Type | Field and Description |
|---|---|
| private LOBStreamControl | |
| private boolean | |
| private int | locator
Locator value for this Blob, used as a handle by the client driver to map operations to the correct Blob on the server side. |
| private boolean | materialized
Tells whether the Blob has been materialized or not. |
| private PositionedStoreStream | myStream
The underlying positionable store stream, if any. |
| private long | streamLength
Length of the stream representing the Blob. |
| private final int | streamPositionOffset
Position offset for the stream representing the Blob, if any. |
| Access | Constructor and Description |
|---|---|
| pack-priv | EmbedBlob(byte[]
A byte array containing the data to be stores in the
Blob. blobBytes, EmbedConnection The EmbedConnection object associated with this Blob object. con)This constructor is used to create a empty Blob object. |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | Returns: true if a match is found, false if not.the byte array to search for, passed in by the user pattern, long the position in the Blob content to start searching from pos)Checks if the pattern (starting from the second byte) appears inside the Blob content. |
| private boolean | Returns: true if a match is found, false if not.the Blob to search for, passed in by the user pattern, long the position in the Blob (this) content to start searching pos)Checks if the pattern (starting from the second byte) appears inside the Blob content. |
| private void | |
| protected void | finalize()
Overrides java. Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
| public void | free()
Implements java. This method frees the |
| public InputStream | Returns: a stream containing theBLOB dataImplements java. Retrieves the |
| public InputStream | Returns: through which the partialBlob value can be read.the offset to the first byte of the partial value to be
retrieved. The first byte in the pos, long Blob is at
position 1the length in bytes of the partial value to be retrieved length)Implements java. Returns an |
| public byte[] | Returns: a byte array containing up tolength
consecutive bytes from the BLOB value designated
by this Blob object, starting with the
byte at position startPos.the ordinal position of the first byte in the
startPos, int BLOB value to be extracted; the first byte is at
position 1is the number of consecutive bytes to be copied length)Implements java. Returns as an array of bytes part or all of the |
| public int | Returns: The locator identifying this lob.Implements org. Return locator for this lob. |
| private SQLException | |
| private int | Returns: The offset into the stream where the user data begins (used if resetting the stream).the source stream dvdStream, EmbedConnection the connection owning the Blob con)Constructs a Blob object on top of a stream. |
| pack-priv boolean | Returns: true if materialized else falseReturns if blob data is stored locally (using LOBStreamControl). |
| public long | Returns: length of theBLOB in bytesImplements java. Returns the number of bytes in the |
| public long | Returns: the position at which the pattern appears, else -1.the byte array for which to search pattern, long the position at which to begin searching; the
first position is 1 start)Implements java. Determines the byte position at which the specified byte
|
| public long | Returns: the position at which the pattern begins, else -1the pattern, long Blob object designating
the BLOB value for which to searchthe position in the start)BLOB value
at which to begin searching; the first position is 1Implements java. Determines the byte position in the |
| private int | Returns: the byte at the current position, or -1 if end of file has been reachedReads one byte from the Blob at the specified position. |
| public OutputStream | Returns: a java.io.OutputStream object to which data can be written- the position in the BLOB object at which to start writing pos)Implements java. JDBC 3.0 Retrieves a stream that can be used to write to the BLOB value that this Blob object represents. |
| private long | Returns: The new position, which will be equal to the requested position.requested Blob position, 0-based logicalPos)Sets the position of the Blob to |
| public int | Returns: The number of bytes written to the BLOB.the position in the BLOB object at which to start writing pos, byte[] the array of bytes to be written to the BLOB value that this
Blob object represents bytes)Implements java. Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written. |
| public int | Returns: The number of bytes written to the BLOB.the position in the BLOB object at which to start writing pos, byte[] the array of bytes to be written to the BLOB value that this
Blob object represents bytes, int the offset into the byte array at which to start reading
the bytes to be written offset, int the number of bytes to be written to the BLOB value from the
array of bytes bytes len)Implements java. Writes all or part of the given array of byte array to the BLOB value that this Blob object represents and returns the number of bytes written. |
| public void | truncate(long
- the length, in bytes, to which the BLOB value that this Blob
object represents should be truncated len)Implements java. JDBC 3.0 Truncates the BLOB value that this Blob object represents to be len bytes in length. |
| control | back to summary |
|---|---|
| private LOBStreamControl control | |
| isValid | back to summary |
|---|---|
| private boolean isValid | |
| locator | back to summary |
|---|---|
| private int locator Locator value for this Blob, used as a handle by the client driver to map operations to the correct Blob on the server side.
| |
| materialized | back to summary |
|---|---|
| private boolean materialized Tells whether the Blob has been materialized or not. Materialization happens when the Blob is updated by the user. A materialized Blob is represented either in memory or in a temporary file on disk, depending on size. A Blob that has not been materialized is represented by a stream into the Derby store, and is read-only. | |
| myStream | back to summary |
|---|---|
| private PositionedStoreStream myStream The underlying positionable store stream, if any.
If | |
| streamLength | back to summary |
|---|---|
| private long streamLength Length of the stream representing the Blob.
Set to -1 when the stream has been | |
| streamPositionOffset | back to summary |
|---|---|
| private final int streamPositionOffset Position offset for the stream representing the Blob, if any.
This offset accounts for the bytes encoding the stream length at the
head of the stream. Data byte | |
| EmbedBlob | back to summary |
|---|---|
| pack-priv EmbedBlob(byte[] blobBytes, EmbedConnection con) throws SQLException This constructor is used to create a empty Blob object. It is used by the Connection interface method createBlob().
| |
| EmbedBlob | back to summary |
|---|---|
| protected EmbedBlob(DataValueDescriptor dvd, EmbedConnection con) throws StandardException, SQLException | |
| checkMatch | back to summary |
|---|---|
| private boolean checkMatch(byte[] pattern, long pos) throws IOException, StandardException Checks if the pattern (starting from the second byte) appears inside the Blob content.
At this point, the first byte of the pattern must already have been
matched, and
| |
| checkMatch | back to summary |
|---|---|
| private boolean checkMatch(Blob pattern, long pos) throws IOException, StandardException Checks if the pattern (starting from the second byte) appears inside the Blob content.
| |
| checkValidity | back to summary |
|---|---|
| private void checkValidity() throws SQLException | |
| finalize | back to summary |
|---|---|
| protected void finalize() Overrides java. Doc from java. Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the
When running in a Java virtual machine in which finalization has been
disabled or removed, the garbage collector will never call
The general contract of
The
The Java programming language does not guarantee which thread will
invoke the
After the
The
Any exception thrown by the
| |
| free | back to summary |
|---|---|
| public void free() throws SQLException Implements java. This method frees the
| |
| getBinaryStream | back to summary |
|---|---|
| public InputStream getBinaryStream() throws SQLException Implements java. Retrieves the
| |
| getBinaryStream | back to summary |
|---|---|
| public InputStream getBinaryStream(long pos, long length) throws SQLException Implements java. Returns an
| |
| getBytes | back to summary |
|---|---|
| public byte[] getBytes(long startPos, int length) throws SQLException Implements java. Returns as an array of bytes part or all of the
| |
| getLocator | back to summary |
|---|---|
| public int getLocator() Implements org. Return locator for this lob.
| |
| handleMyExceptions | back to summary |
|---|---|
| private SQLException handleMyExceptions(Throwable t) throws SQLException | |
| handleStreamValue | back to summary |
|---|---|
| private int handleStreamValue(InputStream dvdStream, EmbedConnection con) throws StandardException, SQLException Constructs a Blob object on top of a stream.
| |
| isMaterialized | back to summary |
|---|---|
| pack-priv boolean isMaterialized() Returns if blob data is stored locally (using LOBStreamControl).
| |
| length | back to summary |
|---|---|
| public long length() throws SQLException Implements java. Returns the number of bytes in the
| |
| position | back to summary |
|---|---|
| public long position(byte[] pattern, long start) throws SQLException Implements java. Determines the byte position at which the specified byte
| |
| position | back to summary |
|---|---|
| public long position(Blob pattern, long start) throws SQLException Implements java. Determines the byte position in the
| |
| read | back to summary |
|---|---|
| private int read(long pos) throws IOException, StandardException Reads one byte from the Blob at the specified position. Depending on the representation, this might result in a read from a byte array, a temporary file on disk or from a Derby store stream.
| |
| setBinaryStream | back to summary |
|---|---|
| public OutputStream setBinaryStream(long pos) throws SQLException Implements java. JDBC 3.0 Retrieves a stream that can be used to write to the BLOB value that this Blob object represents. The stream begins at position pos.
| |
| setBlobPosition | back to summary |
|---|---|
| private long setBlobPosition(long logicalPos) throws StandardException, IOException Sets the position of the Blob to The position is only guaranteed to be valid from the time this method is invoked until the synchronization monitor is released, or until the next invokation of this method. The position is logical in the sense that it specifies the requested position in the Blob content. This position might be at a different position in the underlying representation, for instance the Derby store stream prepends the Blob content with a length field.
| |
| setBytes | back to summary |
|---|---|
| public int setBytes(long pos, byte[] bytes) throws SQLException Implements java. Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written.
| |
| setBytes | back to summary |
|---|---|
| public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException Implements java. Writes all or part of the given array of byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.
| |
| truncate | back to summary |
|---|---|
| public void truncate(long len) throws SQLException Implements java. JDBC 3.0 Truncates the BLOB value that this Blob object represents to be len bytes in length.
| |