final class ClobUpdatableReader
extends java.io.Reader
ClobUpdatableReader
is used to create a Reader
capable of
detecting changes to the underlying source.
This class is aware that the underlying stream can be modified and reinitializes itself if it detects any change in the stream. This invalidates the cache so the changes are reflected immediately.
The task of this class is to detect changes in the underlying Clob. Repositioning is handled by other classes.
Modifier and Type | Field and Description |
---|---|
private EmbedClob |
clob
The Clob object we are reading from.
|
private boolean |
closed
Tells if this reader has been closed.
|
private InternalClob |
iClob
The current internal representation of the Clob content.
|
private long |
lastUpdateCount
The last update count seen on the underlying Clob.
|
private long |
maxPos
Position in Clob where to stop reading unless EOF is reached first.
|
private long |
pos
Character position of this reader (1-based).
|
private java.io.Reader |
streamReader
Reader accessing the Clob data and doing the work.
|
Constructor and Description |
---|
ClobUpdatableReader(EmbedClob clob)
Creates an updatable reader configured with initial position set to the
first character in the Clob and with no imposed length limit.
|
ClobUpdatableReader(EmbedClob clob,
long initialPos,
long length)
Creates an updatable reader configured with the specified initial
position and with an imposed length limit.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this reader.
|
int |
read() |
int |
read(char[] cbuf,
int off,
int len) |
long |
skip(long len) |
private void |
updateReaderIfRequired()
Updates the reader if the underlying data has been modified.
|
private java.io.Reader streamReader
private long pos
private long lastUpdateCount
private final EmbedClob clob
Note that even though the Clob itself is final, the internal representation of the content may change. The reference to the Clob is needed to get a hold of the new internal representation if it is changed.
iClob
private InternalClob iClob
If the user starts out with a read-only Clob and then modifies it, the internal representation will change.
private final long maxPos
private volatile boolean closed
public ClobUpdatableReader(EmbedClob clob) throws java.io.IOException, java.sql.SQLException
clob
- source datajava.io.IOException
- if obtaining the underlying reader failsjava.sql.SQLException
- if obtaining the underlying reader failspublic ClobUpdatableReader(EmbedClob clob, long initialPos, long length) throws java.io.IOException, java.sql.SQLException
clob
- source datainitialPos
- the first character that will be readlength
- the maximum number of characters that will readjava.io.IOException
- if obtaining the underlying reader failsjava.sql.SQLException
- if obtaining the underlying reader failspublic int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public long skip(long len) throws java.io.IOException
skip
in class java.io.Reader
java.io.IOException
public void close() throws java.io.IOException
An IOException
will be thrown if any of the read or skip methods
are called after the reader has been closed.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
- if an error occurs while closingprivate void updateReaderIfRequired() throws java.io.IOException
There are two cases to deal with:
java.io.IOException
- if verifying or updating the reader failsApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.