Top Description Fields Constructors Methods
org.apache.derby.client.am

pack-priv Class UpdateSensitiveClobLocatorReader

extends Reader
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .Reader

Wraps 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

Modifier and TypeField and Description
private ClientClob
private ClientConnection
private long
private long
private BufferedReader
r

private long
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
protected
UpdateSensitiveClobLocatorReader(ClientConnection
connection to be used to read the Clob value from the server
con
,
ClientClob
the Clob object associated with this stream.
clob
)

Initializes the Reader, updateCount, currentPos and the connection to the appropriate values.

protected
UpdateSensitiveClobLocatorReader(ClientConnection
connection to be used to read the Clob value from the server
con
,
ClientClob
the Clob object associated with this reader.
clob
,
long
the position from which the first read begins.
pos
,
long
the length in bytes of the partial value to be retrieved.
len
)

Initializes the Reader, updateCount, currentPos, length and the connection to the appropriate values.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
private void
identifyAndReplaceObseleteStream()

Verifies whether the current updateCount matches the updateCount of the Clob object and if it does not it recreates the stream.

public int
read()

Overrides java.io.Reader.read.

Reads a single character.
public int
read(char[]
Destination buffer
c
,
int
Offset at which to start storing characters
off
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.
private Reader
reCreateStream()

Re-creates the underlying Locator stream with the current position and the length values if specified.

Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadreadyresetskiptransferTo

Field Detail

clobback to summary
private ClientClob clob
conback to summary
private ClientConnection con
currentPosback to summary
private long currentPos
lengthback to summary
private long length
rback to summary
private BufferedReader r
updateCountback to summary
private long updateCount

Constructor Detail

UpdateSensitiveClobLocatorReaderback to summary
protected UpdateSensitiveClobLocatorReader(ClientConnection con, ClientClob clob) throws SqlException

Initializes the Reader, updateCount, currentPos and the connection to the appropriate values.

Parameters
con:ClientConnection

connection to be used to read the Clob value from the server

clob:ClientClob

the Clob object associated with this stream.

UpdateSensitiveClobLocatorReaderback to summary
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:ClientConnection

connection to be used to read the Clob value from the server

clob:ClientClob

the Clob object associated with this reader.

pos:long

the position from which the first read begins.

len:long

the length in bytes of the partial value to be retrieved.

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Exceptions
IOException:
If an I/O error occurs
See Also
java.io.Reader#close()
identifyAndReplaceObseleteStreamback to summary
private void identifyAndReplaceObseleteStream() throws IOException

Verifies whether the current updateCount matches the updateCount of the Clob object and if it does not it recreates the stream.

Exceptions
IOException:
If any exception occurs upon Locator stream creation.
readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Returns:int

The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
See Also
java.io.Reader#read()
readback to summary
public int read(char[] c, int off, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
c:char[]

Destination buffer

off:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
See Also
java.io.Reader#read(char[], int, int)
reCreateStreamback to summary
private Reader reCreateStream() throws SqlException

Re-creates the underlying Locator stream with the current position and the length values if specified.