Package org.apache.derby.client.am
Class UpdateSensitiveLOBLocatorInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.derby.client.am.UpdateSensitiveLOBLocatorInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
UpdateSensitiveBlobLocatorInputStream,UpdateSensitiveClobLocatorInputStream
abstract class UpdateSensitiveLOBLocatorInputStream extends java.io.InputStreamSuper-class of the Update sensitive locator streams. Before a read operation if performed on the stream this stream verifies that the underlying LOB has not changed and if it has it recreates the specific streams. Since Locator streams are specific to Blob and Clob the sub-classes would take care of creating the appropriate streams.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientConnectionconprotected longcurrentPosprivate java.io.BufferedInputStreamisprotected longlengthprivate Loblobprivate longupdateCount
-
Constructor Summary
Constructors Modifier Constructor Description protectedUpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, java.io.InputStream is)Initializes the InputStream, updateCount, currentPos and the connection to the appropriate values.protectedUpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, java.io.InputStream is, long pos, long len)Initializes the InputStream, updateCount, currentPos, length and the connection to the appropriate values.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()private voididentifyAndReplaceObseleteStream()Verifies whether the current updateCount matches the updateCount of the LOB object and if it does not it recreates the stream.intread()intread(byte[] b, int off, int len)protected abstract java.io.InputStreamreCreateStream()Abstract method that will be implemented by the underlying streams specific to Clob and Blob.
-
-
-
Field Detail
-
is
private java.io.BufferedInputStream is
-
con
protected ClientConnection con
-
lob
private Lob lob
-
updateCount
private long updateCount
-
currentPos
protected long currentPos
-
length
protected long length
-
-
Constructor Detail
-
UpdateSensitiveLOBLocatorInputStream
protected UpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, java.io.InputStream is) throws SqlException
Initializes the InputStream, updateCount, currentPos and the connection to the appropriate values.- Parameters:
con- connection to be used to read theLobvalue from the serverlob-Lobobject which could be aBlobor aClob.is- anInputStreamthat contains the appropriate locator stream instance.- Throws:
SqlException
-
UpdateSensitiveLOBLocatorInputStream
protected UpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, java.io.InputStream is, long pos, long len) throws SqlException
Initializes the InputStream, updateCount, currentPos, length and the connection to the appropriate values.- Parameters:
con- connection to be used to read theLobvalue from the serverlob-Lobobject which could be aBlobor aClob.is- anInputStreamthat contains the appropriate locator stream instance.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- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException- See Also:
InputStream.read()
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException- See Also:
InputStream.read(byte[], int, int)
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
identifyAndReplaceObseleteStream
private void identifyAndReplaceObseleteStream() throws java.io.IOExceptionVerifies whether the current updateCount matches the updateCount of the LOB object and if it does not it recreates the stream.- Throws:
java.io.IOException- If any exception occurs upon Locator stream creation.
-
reCreateStream
protected abstract java.io.InputStream reCreateStream() throws SqlExceptionAbstract method that will be implemented by the underlying streams specific to Clob and Blob.- Throws:
SqlException
-
-