Package org.apache.derby.client.am
Class ClobLocatorReader
- java.lang.Object
-
- java.io.Reader
-
- org.apache.derby.client.am.ClobLocatorReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
class ClobLocatorReader extends java.io.ReaderAnReaderthat will use an locator to fetch the Clob value from the server.This
Readerimplementation 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
Fields Modifier and Type Field Description private ClientClobclobThe Clob to be accessed.private ClientConnectionconnectionConnection used to read Clob from server.private longcurrentPosCurrent position in the underlying Clob.private booleanisClosedStores the information to whether this Reader has been closed or not.private longmaxPosPosition in Clob where to stop reading.
-
Constructor Summary
Constructors Constructor Description ClobLocatorReader(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckClosed()Check 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.
-
-
-
Field Detail
-
connection
private final ClientConnection connection
Connection used to read Clob from server.
-
clob
private final ClientClob clob
The Clob to be accessed.
-
currentPos
private long currentPos
Current position in the underlying Clob. Clobs are indexed from 1
-
maxPos
private final long maxPos
Position in Clob where to stop reading. maxPos starts counting from 1.
-
isClosed
private boolean isClosed
Stores the information to whether this Reader has been closed or not. Is set to true if close() has been called. Is false otherwise.
-
-
Constructor Detail
-
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 Detail
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.Reader- Throws:
java.io.IOException- See Also:
This method fetches one character at a time from the server. For more efficient retrieval, use #read(char[]).
-
read
public int read(char[] c, int off, int len) throws java.io.IOException- Specified by:
readin classjava.io.Reader- Throws:
java.io.IOException- See Also:
Reader.read(char[], int, int)
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException- See Also:
Reader.close()
-
checkClosed
private void checkClosed() throws java.io.IOExceptionCheck to see if thisReaderis closed. If it is closed throw anIOExceptionthat states that the stream is closed.- Throws:
java.io.IOException- if isClosed = true.
-
readCharacters
private char[] readCharacters(int len) throws java.io.IOExceptionRead the nextlencharacters of theClobvalue from the server.- Parameters:
len- number of characters to read.- Returns:
char[]containing the read characters.- Throws:
java.io.IOException- Wrapped SqlException if reading from server fails.
-
-