Top Description Fields Constructors Methods
org.apache.derby.client.am

pack-priv abstract Class UpdateSensitiveLOBLocatorInputStream

extends InputStream
Class Inheritance
Known Direct Subclasses
org.apache.derby.client.am.UpdateSensitiveBlobLocatorInputStream, org.apache.derby.client.am.UpdateSensitiveClobLocatorInputStream
Imports
java.io.BufferedInputStream, .IOException, .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

Modifier and TypeField and Description
protected ClientConnection
protected long
private BufferedInputStream
protected long
private Lob
private long

Constructor Summary

AccessConstructor and Description
protected
UpdateSensitiveLOBLocatorInputStream(ClientConnection
connection to be used to read the Lob value from the server
con
,
Lob
Lob object which could be a Blob or a Clob.
lob
,
InputStream
an InputStream that contains the appropriate locator stream instance.
is
)

Initializes the InputStream, updateCount, currentPos and the connection to the appropriate values.

protected
UpdateSensitiveLOBLocatorInputStream(ClientConnection
connection to be used to read the Lob value from the server
con
,
Lob
Lob object which could be a Blob or a Clob.
lob
,
InputStream
an InputStream that contains the appropriate locator stream instance.
is
,
long
the position from which the first read begins.
pos
,
long
the length in bytes of the partial value to be retrieved.
len
)

Initializes the InputStream, updateCount, currentPos, length and the connection to the appropriate values.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
private void
identifyAndReplaceObseleteStream()

Verifies whether the current updateCount matches the updateCount of the LOB object and if it does not it recreates the stream.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.
public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.
protected abstract InputStream
reCreateStream()

Abstract method that will be implemented by the underlying streams specific to Clob and Blob.

Inherited from java.io.InputStream:
availablemarkmarkSupportednullInputStreamreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

conback to summary
protected ClientConnection con
currentPosback to summary
protected long currentPos
isback to summary
private BufferedInputStream is
lengthback to summary
protected long length
lobback to summary
private Lob lob
updateCountback to summary
private long updateCount

Constructor Detail

UpdateSensitiveLOBLocatorInputStreamback to summary
protected UpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, InputStream is) throws SqlException

Initializes the InputStream, updateCount, currentPos and the connection to the appropriate values.

Parameters
con:ClientConnection

connection to be used to read the Lob value from the server

lob:Lob

Lob object which could be a Blob or a Clob.

is:InputStream

an InputStream that contains the appropriate locator stream instance.

UpdateSensitiveLOBLocatorInputStreamback to summary
protected UpdateSensitiveLOBLocatorInputStream(ClientConnection con, Lob lob, InputStream is, long pos, long len) throws SqlException

Initializes the InputStream, updateCount, currentPos, length and the connection to the appropriate values.

Parameters
con:ClientConnection

connection to be used to read the Lob value from the server

lob:Lob

Lob object which could be a Blob or a Clob.

is:InputStream

an InputStream that contains the appropriate locator stream instance.

pos:long

the position from which the first read begins.

len:long

the length in bytes of the partial value to be retrieved.

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
identifyAndReplaceObseleteStreamback to summary
private void identifyAndReplaceObseleteStream() throws IOException

Verifies whether the current updateCount matches the updateCount of the LOB object and if it does not it recreates the stream.

Exceptions
IOException:
If any exception occurs upon Locator stream creation.
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#read()
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
See Also
java.io.InputStream#read(byte[], int, int)
reCreateStreamback to summary
protected abstract InputStream reCreateStream() throws SqlException

Abstract method that will be implemented by the underlying streams specific to Clob and Blob.