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.InputStream
Super-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 ClientConnection
con
protected long
currentPos
private java.io.BufferedInputStream
is
protected long
length
private Lob
lob
private long
updateCount
-
Constructor Summary
Constructors Modifier Constructor Description protected
UpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, java.io.InputStream is)
Initializes the InputStream, updateCount, currentPos and the connection to the appropriate values.protected
UpdateSensitiveLOBLocatorInputStream(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 void
close()
private void
identifyAndReplaceObseleteStream()
Verifies whether the current updateCount matches the updateCount of the LOB object and if it does not it recreates the stream.int
read()
int
read(byte[] b, int off, int len)
protected abstract java.io.InputStream
reCreateStream()
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 theLob
value from the serverlob
-Lob
object which could be aBlob
or aClob
.is
- anInputStream
that 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 theLob
value from the serverlob
-Lob
object which could be aBlob
or aClob
.is
- anInputStream
that 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:
read
in 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:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.read(byte[], int, int)
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
identifyAndReplaceObseleteStream
private void identifyAndReplaceObseleteStream() throws java.io.IOException
Verifies 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 SqlException
Abstract method that will be implemented by the underlying streams specific to Clob and Blob.- Throws:
SqlException
-
-