Package org.apache.derby.client.am
Class UpdateSensitiveClobLocatorReader
- java.lang.Object
-
- java.io.Reader
-
- org.apache.derby.client.am.UpdateSensitiveClobLocatorReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
class UpdateSensitiveClobLocatorReader extends java.io.ReaderWraps a Buffered Clob locator reader and watches out for updates on the Clob associated with it. Before a read operation is performed on the Reader this stream verifies that the underlying Clob has not changed and if it has it recreates the specific streams.
-
-
Field Summary
Fields Modifier and Type Field Description private ClientClobclobprivate ClientConnectionconprivate longcurrentPosprivate longlengthprivate java.io.BufferedReaderrprivate longupdateCount
-
Constructor Summary
Constructors Modifier Constructor Description protectedUpdateSensitiveClobLocatorReader(ClientConnection con, ClientClob clob)Initializes the Reader, updateCount, currentPos and the connection to the appropriate values.protectedUpdateSensitiveClobLocatorReader(ClientConnection con, ClientClob clob, long pos, long len)Initializes the Reader, updateCount, currentPos, length and the connection to the appropriate values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private voididentifyAndReplaceObseleteStream()Verifies whether the current updateCount matches the updateCount of the Clob object and if it does not it recreates the stream.intread()intread(char[] c, int off, int len)private java.io.ReaderreCreateStream()Re-creates the underlying Locator stream with the current position and the length values if specified.
-
-
-
Field Detail
-
r
private java.io.BufferedReader r
-
con
private ClientConnection con
-
clob
private ClientClob clob
-
updateCount
private long updateCount
-
currentPos
private long currentPos
-
length
private long length
-
-
Constructor Detail
-
UpdateSensitiveClobLocatorReader
protected UpdateSensitiveClobLocatorReader(ClientConnection con, ClientClob clob) throws SqlException
Initializes the Reader, updateCount, currentPos and the connection to the appropriate values.- Parameters:
con- connection to be used to read theClobvalue from the serverclob- theClobobject associated with this stream.- Throws:
SqlException
-
UpdateSensitiveClobLocatorReader
protected UpdateSensitiveClobLocatorReader(ClientConnection con, ClientClob clob, long pos, long len) throws SqlException
Initializes the Reader, updateCount, currentPos, length and the connection to the appropriate values.- Parameters:
con- connection to be used to read theClobvalue from the serverclob- theClobobject associated with this reader.pos- the position from which the first read begins.len- the length in bytes 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:
Reader.read()
-
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()
-
identifyAndReplaceObseleteStream
private void identifyAndReplaceObseleteStream() throws java.io.IOExceptionVerifies whether the current updateCount matches the updateCount of the Clob object and if it does not it recreates the stream.- Throws:
java.io.IOException- If any exception occurs upon Locator stream creation.
-
reCreateStream
private java.io.Reader reCreateStream() throws SqlExceptionRe-creates the underlying Locator stream with the current position and the length values if specified.- Throws:
SqlException
-
-