Class ClobUpdatableReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EmbedClob
The Clob object we are reading from.private boolean
Tells if this reader has been closed.private InternalClob
The current internal representation of the Clob content.private long
The last update count seen on the underlying Clob.private final long
Position in Clob where to stop reading unless EOF is reached first.private long
Character position of this reader (1-based).private Reader
Reader accessing the Clob data and doing the work. -
Constructor Summary
ConstructorsConstructorDescriptionClobUpdatableReader
(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. -
Method Summary
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, transferTo
-
Field Details
-
streamReader
Reader accessing the Clob data and doing the work. -
pos
private long posCharacter position of this reader (1-based). -
lastUpdateCount
private long lastUpdateCountThe last update count seen on the underlying Clob. -
clob
The Clob object we are reading from.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.
- See Also:
-
iClob
The current internal representation of the Clob content.If the user starts out with a read-only Clob and then modifies it, the internal representation will change.
-
maxPos
private final long maxPosPosition in Clob where to stop reading unless EOF is reached first. -
closed
private volatile boolean closedTells if this reader has been closed.
-
-
Constructor Details
-
ClobUpdatableReader
Creates an updatable reader configured with initial position set to the first character in the Clob and with no imposed length limit.- Parameters:
clob
- source data- Throws:
IOException
- if obtaining the underlying reader failsSQLException
- if obtaining the underlying reader fails
-
ClobUpdatableReader
public ClobUpdatableReader(EmbedClob clob, long initialPos, long length) throws IOException, SQLException Creates an updatable reader configured with the specified initial position and with an imposed length limit.- Parameters:
clob
- source datainitialPos
- the first character that will be readlength
- the maximum number of characters that will read- Throws:
IOException
- if obtaining the underlying reader failsSQLException
- if obtaining the underlying reader fails
-
-
Method Details
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
read
- Specified by:
read
in classReader
- Throws:
IOException
-
skip
- Overrides:
skip
in classReader
- Throws:
IOException
-
close
Closes this reader.An
IOException
will be thrown if any of the read or skip methods are called after the reader has been closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- if an error occurs while closing
-
updateReaderIfRequired
Updates the reader if the underlying data has been modified.There are two cases to deal with:
- The underlying data of the internal Clob representation has been modified.
- The internal Clob representation has changed.
- Throws:
IOException
- if verifying or updating the reader fails
-