Class ClobLocatorReader
java.lang.Object
java.io.Reader
org.apache.derby.client.am.ClobLocatorReader
- All Implemented Interfaces:
Closeable, AutoCloseable, Readable
An
Reader that will use an locator to fetch the
Clob value from the server.
This Reader implementation is pretty basic. No
buffering of data is done. Hence, for efficiency #read(char[])
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 ClientClobThe Clob to be accessed.private final ClientConnectionConnection used to read Clob from server.private longCurrent position in the underlying Clob.private booleanStores the information to whether this Reader has been closed or not.private final longPosition in Clob where to stop reading. maxPos starts counting from 1. -
Constructor Summary
ConstructorsConstructorDescriptionClobLocatorReader(ClientConnection connection, ClientClob clob) Create anReaderfor reading theClobvalue represented by the given locator basedClobobject.ClobLocatorReader(ClientConnection connection, ClientClob clob, long pos, long len) Create anReaderfor reading theClobvalue represented by the given locator basedClobobject. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCheck to see if thisReaderis closed.voidclose()intread()intread(char[] c, int off, int len) private char[]readCharacters(int len) Read the nextlencharacters of theClobvalue from the server.Methods inherited from class Reader
mark, markSupported, nullReader, of, read, read, readAllAsString, readAllLines, ready, reset, skip, 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 -
maxPos
private final long maxPosPosition in Clob where to stop reading. maxPos starts counting from 1. -
isClosed
private boolean isClosedStores the information to whether this Reader has been closed or not. Is set to true if close() has been called. Is false otherwise.
-
-
Constructor Details
-
ClobLocatorReader
ClobLocatorReader(ClientConnection connection, ClientClob clob) throws SqlException Create anReaderfor reading theClobvalue represented by the given locator basedClobobject.- Parameters:
connection- connection to be used to read theClobvalue from the serverclob-Clobobject that contains locator for theClobvalue on the server.- Throws:
SqlException
-
ClobLocatorReader
ClobLocatorReader(ClientConnection connection, ClientClob clob, long pos, long len) throws SqlException Create anReaderfor reading theClobvalue represented by the given locator basedClobobject.- Parameters:
connection- connection to be used to read theClobvalue from the serverclob-Clobobject that contains locator for theClobvalue on the server.pos- The offset to the first character of the partial value to be retrieved.len- The length in characters of the partial value to be retrieved.- Throws:
SqlException
-
-
Method Details
-
read
- Overrides:
readin classReader- Throws:
IOException- See Also:
-
read
- Specified by:
readin classReader- Throws:
IOException- See Also:
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException- See Also:
-
checkClosed
Check to see if thisReaderis closed. If it is closed throw anIOExceptionthat states that the stream is closed.- Throws:
IOException- if isClosed = true.
-
readCharacters
Read the nextlencharacters of theClobvalue from the server.- Parameters:
len- number of characters to read.- Returns:
char[]containing the read characters.- Throws:
IOException- Wrapped SqlException if reading from server fails.
-