java.io.Closeable
, java.lang.AutoCloseable
class ClobLocatorInputStream
extends java.io.InputStream
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.
Modifier and Type | Field | Description |
---|---|---|
private ClientClob |
clob |
The Clob to be accessed.
|
private ClientConnection |
connection |
Connection used to read Clob from server.
|
private long |
currentPos |
Current position in the underlying Clob.
|
Constructor | Description |
---|---|
ClobLocatorInputStream(ClientConnection connection,
ClientClob clob) |
Create an
InputStream for reading the
Clob value represented by the given locator based
Clob object. |
ClobLocatorInputStream(ClientConnection connection,
ClientClob clob,
long pos) |
Create an
InputStream for reading the
Clob value represented by the given locator based
Clob object. |
Modifier and Type | Method | Description |
---|---|---|
private byte[] |
getBytesFromString(java.lang.String str) |
Returns a
Byte array from the
String passed as Input. |
int |
read() |
|
int |
read(byte[] b,
int off,
int len) |
|
private byte[] |
readBytes(int len) |
Read the next
len bytes of the Clob
value from the server. |
private final ClientConnection connection
private final ClientClob clob
private long currentPos
ClobLocatorInputStream(ClientConnection connection, ClientClob clob) throws SqlException
InputStream
for reading the
Clob
value represented by the given locator based
Clob
object.connection
- connection to be used to read the
Clob
value from the serverclob
- Clob
object that contains locator for
the Clob
value on the server.SqlException
ClobLocatorInputStream(ClientConnection connection, ClientClob clob, long pos) throws SqlException
InputStream
for reading the
Clob
value represented by the given locator based
Clob
object.connection
- connection to be used to read the
Clob
value from the serverclob
- Clob
object that contains locator for
the Clob
value on the server.pos
- the position inside the Clob from which
the reading must begin.
SqlException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
This method fetches one byte at a time from the server. For more
efficient retrieval, use #read(byte[]).
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
InputStream.read(byte[], int, int)
private byte[] readBytes(int len) throws java.io.IOException
len
bytes of the Clob
value from the server.len
- number of bytes to readbyte[]
containing the read bytesjava.io.IOException
- Wrapped SqlException if reading
from server fails.private byte[] getBytesFromString(java.lang.String str)
Byte
array from the
String
passed as Input.str
- the input String
.Byte
corresponding
to the String
that was
input.Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.