Character positions given as input to methods in this class are always 1-based. Byte positions are always 0-based.
| Modifier and Type | Class and Description |
|---|---|
| private static class | TemporaryClob.
A simple class to hold the byte position for a character position. |
| Modifier and Type | Field and Description |
|---|---|
| private final LOBStreamControl | bytes
Underlying structure holding this Clobs raw bytes. |
| private long | cachedCharLength
Cached character length of the Clob. |
| private ConnectionChild | conChild
Connection child assoicated with this Clob. |
| private UTF8Reader | internalReader
Shared internal reader, closed when the Clob is released. |
| private final TemporaryClob. | posCache
Simple one-entry cache for character-byte position. |
| private boolean | released
Tells whether this Clob has been released or not. |
| private FilterReader | unclosableInternalReader
The internal reader wrapped so that it cannot be closed. |
| Access | Constructor and Description |
|---|---|
| pack-priv | TemporaryClob(ConnectionChild
connection object used to obtain synchronization object conChild)Constructs a |
| pack-priv | TemporaryClob(String
initial value in String data, ConnectionChild connection object used to obtain synchronization object conChild)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| private final void | |
| pack-priv static InternalClob | Returns: A read-write Clob.name of the assoicated database dbName, ConnectionChild assoiated connection child conChild, InternalClob the Clob whose content to clone clob)Clones the content of another internal Clob. |
| pack-priv static InternalClob | Returns: A read-write Clob.name of the assoicated database dbName, ConnectionChild assoiated connection child conChild, InternalClob the Clob whose content to clone clob, long number of chars in new InternalClob length)Clones the content of another internal Clob. |
| private void | copyClobContent(InternalClob
the Clob to copy from clob)Copies the content of another Clob into this one. |
| private void | copyClobContent(InternalClob
the Clob to copy from clob, long number of chars to copy charLength)Copies the content of another Clob into this one. |
| private byte[] | Returns: Byte array representing the string in modified UTF-8 encoding.string to represent with modified UTF-8 encoding str)Converts a string into the modified UTF-8 byte encoding. |
| public synchronized long | |
| private long | Returns: Stream position in bytes for the given character position.character position charPos)Finds the corresponding byte position for the given UTF-8 character
position, starting from the byte position |
| public synchronized long | Returns: The length of the Clob in number of characters.Implements org. Returns number of characters in the Clob. |
| public synchronized long | Returns: The number of characters in the Clob, or-1 if unknown.Implements org. Returns the cached character count for the Clob, if any. |
| private final CharacterStreamDescriptor | Returns: A character stream descriptor.Returns a character stream descriptor for the stream. |
| public Reader | getInternalReader(long
character position. The first character is at
position characterPosition)1.Implements org. Returns an internal reader for the Clob content, initialized at the specified character position. |
| public synchronized InputStream | Returns: A stream serving the raw bytes of the stream, initialized at byte position0.Implements org. Returns a stream serving the raw bytes of this Clob. |
| public synchronized Reader | Returns: AReader with the underlying CLOB
value as source.initial position of the returned pos)Reader in
number of characters. Expected to be non-negative. The first
character is at position 0.Implements org. Constructs and returns a |
| public long | Returns: Update count.Implements org. Returns the update count of this Clob. |
| public synchronized Writer | Returns: AWriter to write to the CLOB value.the initial position in bytes for the pos)WriterImplements org. Constructs and returns a |
| public synchronized long | Returns: Number of characters inserted.the string to insert str, long the character position to insert the string at insertionPoint)Implements org. Inserts a string at the given position. |
| public synchronized boolean | Returns: true if released, false if not.Implements org. Tells if this Clob has been released. |
| public boolean | Returns: trueImplements org. Tells if this Clob is intended to be writable. |
| public synchronized void | release()
Implements org. Releases this Clob by freeing assoicated resources. |
| public synchronized void | truncate(long
the new length, in characters, of the Clob newCharLength)Implements org. Truncate the Clob to the specifiec size. |
| private final void | updateInternalState(long
the position where the Clob change started charChangePosition)Updates the internal state after a modification has been performed on the Clob content. |
| bytes | back to summary |
|---|---|
| private final LOBStreamControl bytes Underlying structure holding this Clobs raw bytes. | |
| cachedCharLength | back to summary |
|---|---|
| private long cachedCharLength Cached character length of the Clob.
A value of | |
| conChild | back to summary |
|---|---|
| private ConnectionChild conChild Connection child assoicated with this Clob. Currently only used for synchronization in *some* streams associated with the Clob. This suggests something is off wrt. synchronization. | |
| internalReader | back to summary |
|---|---|
| private UTF8Reader internalReader Shared internal reader, closed when the Clob is released.
This is a performance optimization, and the stream is shared between
"one time" operations, for instance Note Do not publish this reader to the end-user. | |
| posCache | back to summary |
|---|---|
| private final TemporaryClob. Simple one-entry cache for character-byte position. | |
| released | back to summary |
|---|---|
| private boolean released Tells whether this Clob has been released or not. | |
| unclosableInternalReader | back to summary |
|---|---|
| private FilterReader unclosableInternalReader The internal reader wrapped so that it cannot be closed. | |
| TemporaryClob | back to summary |
|---|---|
| pack-priv TemporaryClob(ConnectionChild conChild) Constructs a
| |
| TemporaryClob | back to summary |
|---|---|
| pack-priv TemporaryClob(String data, ConnectionChild conChild) throws IOException, StandardException Constructs a
| |
| checkIfValid | back to summary |
|---|---|
| private final void checkIfValid() Makes sure the Clob has not been released. All operations are invalid on a released Clob.
| |
| cloneClobContent | back to summary |
|---|---|
| pack-priv static InternalClob cloneClobContent(String dbName, ConnectionChild conChild, InternalClob clob) throws IOException, SQLException Clones the content of another internal Clob.
| |
| cloneClobContent | back to summary |
|---|---|
| pack-priv static InternalClob cloneClobContent(String dbName, ConnectionChild conChild, InternalClob clob, long length) throws IOException, SQLException Clones the content of another internal Clob.
| |
| copyClobContent | back to summary |
|---|---|
| private void copyClobContent(InternalClob clob) throws IOException, SQLException Copies the content of another Clob into this one.
| |
| copyClobContent | back to summary |
|---|---|
| private void copyClobContent(InternalClob clob, long charLength) throws IOException, SQLException Copies the content of another Clob into this one.
| |
| getByteFromString | back to summary |
|---|---|
| private byte[] getByteFromString(String str) Converts a string into the modified UTF-8 byte encoding.
| |
| getByteLength | back to summary |
|---|---|
| public synchronized long getByteLength() throws IOException Returns the size of the Clob in bytes.
| |
| getBytePosition | back to summary |
|---|---|
| private long getBytePosition(final long charPos) throws IOException Finds the corresponding byte position for the given UTF-8 character
position, starting from the byte position
| |
| getCharLength | back to summary |
|---|---|
| public synchronized long getCharLength() throws IOException Implements org. Returns number of characters in the Clob.
| |
| getCharLengthIfKnown | back to summary |
|---|---|
| public synchronized long getCharLengthIfKnown() Implements org. Returns the cached character count for the Clob, if any.
| |
| getCSD | back to summary |
|---|---|
| private final CharacterStreamDescriptor getCSD() throws IOException Returns a character stream descriptor for the stream.
All streams from the underlying source (
| |
| getInternalReader | back to summary |
|---|---|
| public Reader getInternalReader(long characterPosition) throws IOException, SQLException Implements org. Doc from org. Returns an internal reader for the Clob content, initialized at the specified character position.
This method can return a shared reader object, avoiding instantiation and
repositioning costs for internal operations where the stream itself is
not published to the end-user. One such example is
| |
| getRawByteStream | back to summary |
|---|---|
| public synchronized InputStream getRawByteStream() throws IOException Implements org. Returns a stream serving the raw bytes of this Clob. The stream is managed by the underlying byte store, and can serve bytes both from memory and from a file on disk.
| |
| getReader | back to summary |
|---|---|
| public synchronized Reader getReader(long pos) throws IOException, SQLException Implements org. Constructs and returns a
| |
| getUpdateCount | back to summary |
|---|---|
| public long getUpdateCount() Implements org. Returns the update count of this Clob.
| |
| getWriter | back to summary |
|---|---|
| public synchronized Writer getWriter(long pos) throws IOException, SQLException Implements org. Constructs and returns a
| |
| insertString | back to summary |
|---|---|
| public synchronized long insertString(String str, long insertionPoint) throws IOException, SQLException Implements org. Inserts a string at the given position.
| |
| isReleased | back to summary |
|---|---|
| public synchronized boolean isReleased() Implements org. Tells if this Clob has been released.
| |
| isWritable | back to summary |
|---|---|
| public boolean isWritable() Implements org. Tells if this Clob is intended to be writable.
| |
| release | back to summary |
|---|---|
| public synchronized void release() throws IOException Implements org. Releases this Clob by freeing assoicated resources.
| |
| truncate | back to summary |
|---|---|
| public synchronized void truncate(long newCharLength) throws IOException, SQLException Implements org. Truncate the Clob to the specifiec size.
| |
| updateInternalState | back to summary |
|---|---|
| private final void updateInternalState(long charChangePosition) Updates the internal state after a modification has been performed on the Clob content. Currently the state update consists of dicarding the internal reader to stop it from delivering stale data, to reset the byte/char position cache if necessary, and to reset the cached length.
| |
The implementation is very simple and is basically intended to speed up writing a sequence of consequtive characters one character at a time. Even though this should be avoided if possible, the penalty of updating a large Clob this way and finding the correct byte position by navigating from the start of the byte stream each time is so severe that a simple caching mechanism should be in place. Note that for other encodings than UTF-8, this might not be a problem if the mapping between character position and byte position is one-to-one.
Note that to ensure consistency between character and byte positions, access to this class must be synchronized externally to avoid caller 1 getting the character position, then caller 2 updates the cached values and then caller 1 gets the updated byte position.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv long | Returns: The byte position for the last cached character position.Returns the last cached byte position. |
| pack-priv long | |
| pack-priv void | |
| pack-priv void | updateCachedPos(long
the character position to cache the byte position for charPos, long byte position for the specified character position bytePos)Updates the position cache. |
| bytePos | back to summary |
|---|---|
| private long bytePos | |
| charPos | back to summary |
|---|---|
| private long charPos | |
| CharToBytePositionCache | back to summary |
|---|---|
| pack-priv CharToBytePositionCache() | |
| getBytePos | back to summary |
|---|---|
| pack-priv long getBytePos() Returns the last cached byte position.
| |
| getCharPos | back to summary |
|---|---|
| pack-priv long getCharPos() Returns the last cached character position.
| |
| reset | back to summary |
|---|---|
| pack-priv void reset() Resets the position cache. | |
| updateCachedPos | back to summary |
|---|---|
| pack-priv void updateCachedPos(long charPos, long bytePos) Updates the position cache.
| |