Package org.apache.derby.client.am
Class ClobLocatorInputStream
java.lang.Object
java.io.InputStream
org.apache.derby.client.am.ClobLocatorInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An
InputStream
that will use an locator to fetch the
Clob 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 ClientClob
The Clob to be accessed.private final ClientConnection
Connection used to read Clob from server.private long
Current position in the underlying Clob. -
Constructor Summary
ConstructorsConstructorDescriptionClobLocatorInputStream
(ClientConnection connection, ClientClob clob) Create anInputStream
for reading theClob
value represented by the given locator basedClob
object.ClobLocatorInputStream
(ClientConnection connection, ClientClob clob, long pos) Create anInputStream
for reading theClob
value represented by the given locator basedClob
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]
getBytesFromString
(String str) Returns aByte
array from theString
passed as Input.int
read()
int
read
(byte[] b, int off, int len) private byte[]
readBytes
(int len) Read the nextlen
bytes of theClob
value from the server.Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
connection
Connection used to read Clob from server. -
clob
The Clob to be accessed. -
currentPos
private long currentPosCurrent position in the underlying Clob. Clobs are indexed from 1
-
-
Constructor Details
-
ClobLocatorInputStream
ClobLocatorInputStream(ClientConnection connection, ClientClob clob) throws SqlException Create anInputStream
for reading theClob
value represented by the given locator basedClob
object.- Parameters:
connection
- connection to be used to read theClob
value from the serverclob
-Clob
object that contains locator for theClob
value on the server.- Throws:
SqlException
-
ClobLocatorInputStream
ClobLocatorInputStream(ClientConnection connection, ClientClob clob, long pos) throws SqlException Create anInputStream
for reading theClob
value represented by the given locator basedClob
object.- Parameters:
connection
- connection to be used to read theClob
value from the serverclob
-Clob
object that contains locator for theClob
value on the server.pos
- the position inside theClob
from which the reading must begin.
- Throws:
SqlException
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
- See Also:
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
- See Also:
-
readBytes
Read the nextlen
bytes of theClob
value 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.
-
getBytesFromString
Returns aByte
array from theString
passed as Input.- Parameters:
str
- the inputString
.- Returns:
- The
Byte
corresponding to theString
that was input.
-