Top Description Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv final Class StandardEXTDTAReaderInputStream

extends EXTDTAReaderInputStream
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream

Implementation of InputStream which get EXTDTA from the DDMReader. This class can be used to stream LOBs from Network client to the Network server.

Field Summary

Modifier and TypeField and Description
private ByteArrayInputStream
currentBuffer

Current data buffer

private final long
length

Length of stream

private final DDMReader
reader

DDMReader.

private long
remainingBytes

Remaining bytes in stream

Inherited from org.apache.derby.impl.drda.EXTDTAReaderInputStream:
isLayerBStreamreadStatusByte

Constructor Summary

AccessConstructor and Description
pack-priv
StandardEXTDTAReaderInputStream(final DDMReader
The reader to get data from
reader
,
boolean
whether or not to read the trailing Derby-specific EXTDTA stream status byte
readStatusByte
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public final int

Returns:

the number of bytes that can be read from this input stream without blocking.
available
()

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
pack-priv final long

Returns:

The number of bytes that will be returned by this stream.
getLength
()

Returns the number of bytes returned by this stream.

private void
nextBuffer()

Fetches the next buffer.

protected void
public final int

Returns:

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

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.
public final int

Returns:

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.
read
(final byte[]
the buffer into which the data is read.
b
,
final 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.
Inherited from org.apache.derby.impl.drda.EXTDTAReaderInputStream:
checkStatusgetStatusisLayerBStreamisStatusSetsetSuppressExceptionthrowEXTDTATransferException

Field Detail

currentBufferback to summary
private ByteArrayInputStream currentBuffer

Current data buffer

lengthback to summary
private final long length

Length of stream

readerback to summary
private final DDMReader reader

DDMReader. Used to get more data.

remainingBytesback to summary
private long remainingBytes

Remaining bytes in stream

Constructor Detail

StandardEXTDTAReaderInputStreamback to summary
pack-priv StandardEXTDTAReaderInputStream(final DDMReader reader, boolean readStatusByte) throws DRDAProtocolException

Constructor.

Parameters
reader:DDMReader

The reader to get data from

readStatusByte:boolean

whether or not to read the trailing Derby-specific EXTDTA stream status byte

Exceptions
DRDAProtocolException:
if thrown while initializing current buffer.

Method Detail

availableback to summary
public final int available()

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

This subclass implements this method by calling available on the current buffer, which is a ByteInputStreamReader.

Returns:int

the number of bytes that can be read from this input stream without blocking.

getLengthback to summary
pack-priv final long getLength()

Returns the number of bytes returned by this stream.

The length includes data which has been already read at the invocation time, but doesn't include any meta data (like the Derby-specific EXTDTA status byte).

Returns:long

The number of bytes that will be returned by this stream.

nextBufferback to summary
private void nextBuffer() throws IOException

Fetches the next buffer.

Exceptions
IOException:
if fetching the buffer fails
onClientSideStreamingErrorback to summary
protected void onClientSideStreamingError()

Implements abstract org.apache.derby.impl.drda.EXTDTAReaderInputStream.onClientSideStreamingError.

Cleans up and closes the stream.

readback to summary
public final int read() throws IOException

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

This subclass of InputStream implements this method by reading the next byte from the current buffer. If there is more data, it will be requested a new buffer from the DDMReader.

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 final int read(final byte[] b, final int off, int len) throws IOException

Overrides 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, possibly zero. The number of bytes actually read is returned as an integer. This subclass implements this method by calling this method on the current buffer, which is an instance of ByteArrayInputStream. If the current buffer does not have any data, it will be requested a new buffer from the DDMReader.

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 an I/O error occurs.
NullPointerException:
if b is null.
See Also
java.io.InputStream#read(byte[], int, int)