Class BlobLocatorInputStream
java.lang.Object
java.io.InputStream
org.apache.derby.client.am.BlobLocatorInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
An
InputStream that will use an locator to fetch the
Blob value from the server.
Closing a ByteArrayInputStream has no effect. The methods in
this class can be called after the stream has been closed without
generating an IOException.
This InputStream implementation is pretty basic. No
buffering of data is done. Hence, for efficiency #read(byte[])
should be used instead of #read(). Marks are not supported, but it
should be pretty simple to extend the implementation to support
this. A more efficient skip implementation should also be
straight-forward.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClientBlobThe Blob to be accessed.private final ClientConnectionConnection used to read Blob from server.private longCurrent position in the underlying Blob.private final longPosition in Blob where to stop reading. maxPos starts counting from 1. -
Constructor Summary
ConstructorsConstructorDescriptionBlobLocatorInputStream(ClientConnection connection, ClientBlob blob) Create anInputStreamfor reading theBlobvalue represented by the given locator basedBlobobject.BlobLocatorInputStream(ClientConnection connection, ClientBlob blob, long position, long length) Create anInputStreamfor reading theBlobvalue represented by the given locator basedBlobobject. -
Method Summary
Methods inherited from class InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
connection
Connection used to read Blob from server. -
blob
The Blob to be accessed. -
currentPos
private long currentPosCurrent position in the underlying Blob. Blobs are indexed from 1 -
maxPos
private final long maxPosPosition in Blob where to stop reading. maxPos starts counting from 1.
-
-
Constructor Details
-
BlobLocatorInputStream
BlobLocatorInputStream(ClientConnection connection, ClientBlob blob) throws SqlException Create anInputStreamfor reading theBlobvalue represented by the given locator basedBlobobject.- Parameters:
connection- connection to be used to read theBlobvalue from the serverblob-Blobobject that contains locator for theBlobvalue on the server.- Throws:
SqlException- if an error occurs when obtaining the length of theBlob.
-
BlobLocatorInputStream
BlobLocatorInputStream(ClientConnection connection, ClientBlob blob, long position, long length) throws SqlException Create anInputStreamfor reading theBlobvalue represented by the given locator basedBlobobject.- Parameters:
connection- connection to be used to read theBlobvalue from the serverblob-Blobobject that contains locator for theBlobvalue on the server.position- the position in theBlobof the first byte to read.length- the maximum number of bytes to read from theBlob.- Throws:
SqlException- if an error occurs when obtaining the length of theBlob.
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException- See Also:
-
read
- Overrides:
readin classInputStream- Throws:
IOException- See Also:
-
readBytes
Read the nextlenbytes of theBlobvalue from the server.- Parameters:
len- number of bytes to read- Returns:
byte[]containing the read bytes- Throws:
IOException- Wrapped SqlException if reading from server fails.
-