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

pack-priv abstract Class EXTDTAReaderInputStream

extends InputStream
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.drda.LayerBStreamedEXTDTAReaderInputStream, org.apache.derby.impl.drda.StandardEXTDTAReaderInputStream
Imports
java.io.IOException, .InputStream, org.apache.derby.shared.common.reference.DRDAConstants, .SQLState, .MessageId, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.io.DerbyIOException

Implementation of InputStream which get EXTDTA from the DDMReader.

This class can be used to stream LOBs from Network client to the Network server.

To be able to correctly stream data from the client without reading the while value up front, a trailing Derby-specific status byte was introduced (version 10.6). It is used by the client to tell the server if the data it received was valid, or if it detected an error while streaming the data. The DRDA protocol, or at least Derby's implementation of it, doesn't enable the client to inform the server about the error whilst streaming (there is a mechanism in DRDA to interrupt a running request, but it didn't seem like a feasible approach in this case).

Field Summary

Modifier and TypeField and Description
protected final boolean
isLayerBStream

Whether or not the subclass is a layer B stream.

protected final boolean
readStatusByte

Whether or not to read the trailing Derby-specific status byte.

private byte
status

The status Derby-specific status byte, if any.

private boolean
statusSet

Tells if the status byte has been set.

private boolean
suppressException

Whether or not to suppress the exception when an error is indicated by the status byte.

Constructor Summary

AccessConstructor and Description
protected
EXTDTAReaderInputStream(boolean
whether or not DDM layer B streaming is being used
layerB
,
boolean
whether or not to read the trailing Derby-specific status byte
readStatusByte
)

Initializes the class.

Method Summary

Modifier and TypeMethod and Description
protected void
checkStatus(int
the status flag sent by the client
clientStatus
)

Interprets the Derby-specific status byte, and throws an exception if an error condition has been detected on the client.

public byte

Returns:

The status byte.
getStatus
()

Returns the status byte.

public boolean
public boolean

Returns:

true if set, false if not.
isStatusSet
()

Returns whether the status has been set or not.

protected abstract void
onClientSideStreamingError()

Performs necessary clean up when an error is signalled by the client.

private void
setStatus(int
the status
status
)

Saves the status byte read off the wire.

pack-priv void
setSuppressException(boolean
true to suppress, false to throw exception if an error condition is indicated by the status flag
flag
)

Sets whether or not to suppress the exception when setting the status.

pack-priv static void
throwEXTDTATransferException(int
the EXTDTA status byte received from the client, should not be DRDAConstants#STREAM_OK
status
)

Throws an exception as mandated by the EXTDTA status byte.

Inherited from java.io.InputStream:
availableclosemarkmarkSupportednullInputStreamreadreadreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

isLayerBStreamback to summary
protected final boolean isLayerBStream

Whether or not the subclass is a layer B stream.

readStatusByteback to summary
protected final boolean readStatusByte

Whether or not to read the trailing Derby-specific status byte.

statusback to summary
private byte status

The status Derby-specific status byte, if any.

See Also
isStatusSet()
statusSetback to summary
private boolean statusSet

Tells if the status byte has been set.

See Also
checkStatus(int)
suppressExceptionback to summary
private boolean suppressException

Whether or not to suppress the exception when an error is indicated by the status byte.

Constructor Detail

EXTDTAReaderInputStreamback to summary
protected EXTDTAReaderInputStream(boolean layerB, boolean readStatusByte)

Initializes the class.

Parameters
layerB:boolean

whether or not DDM layer B streaming is being used

readStatusByte:boolean

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

Method Detail

checkStatusback to summary
protected void checkStatus(int clientStatus) throws IOException

Interprets the Derby-specific status byte, and throws an exception if an error condition has been detected on the client.

Parameters
clientStatus:int

the status flag sent by the client

Exceptions
IOException:
if the status byte indicates an error condition
getStatusback to summary
public byte getStatus()

Returns the status byte.

Note

Check if the status byte has been set by calling isStatusSet().

Returns:byte

The status byte.

isLayerBStreamback to summary
public boolean isLayerBStream()
isStatusSetback to summary
public boolean isStatusSet()

Returns whether the status has been set or not.

Returns:boolean

true if set, false if not.

onClientSideStreamingErrorback to summary
protected abstract void onClientSideStreamingError()

Performs necessary clean up when an error is signalled by the client.

setStatusback to summary
private void setStatus(int status)

Saves the status byte read off the wire.

Parameters
status:int

the status

See Also
DRDAConstants
setSuppressExceptionback to summary
pack-priv void setSuppressException(boolean flag)

Sets whether or not to suppress the exception when setting the status.

Parameters
flag:boolean

true to suppress, false to throw exception if an error condition is indicated by the status flag

throwEXTDTATransferExceptionback to summary
pack-priv static void throwEXTDTATransferException(int status) throws IOException

Throws an exception as mandated by the EXTDTA status byte.

Parameters
status:int

the EXTDTA status byte received from the client, should not be DRDAConstants#STREAM_OK

Exceptions
IOException:
the exception generated based on the status byte