Class DDMReader
- java.lang.Object
-
- org.apache.derby.impl.drda.DDMReader
-
class DDMReader extends java.lang.ObjectThe DDMReader is used to read DRDA protocol. DRDA Protocol is divided into three layers corresponding to the DDM three-tier architecture. For each layer, their is a DSS (Data Stream Structure) defined. Layer A Communications management services Layer B Agent services Layer C Data management servicesAt layer A are request, reply and data correlation, structure chaining, continuation or termination of chains when errors are detected, interleaving and multi-leaving request, reply, and data DSSs for multitasking environments. For TCP/IP, the format of the DDM envelope is 2 bytes Length of the data 1 byte 'D0' - indicates DDM data 1 byte DDM format byte(DSSFMT) - type of DSS(RQSDSS,RPYDSS), whether it is chained, information about the next chained DSS 2 bytes request correlation identifier
The correlation identifier ties together a request, the request data and the reply. In a chained DSS, each request has a correlation identifier which is higher than the previous request (all correlation identifiers must be greater than 0).
At layer B are object mapping, object validation and command routing. Layer B objects with data 5 bytes less than 32K bytes consist of 2 bytes Length 2 bytes Type of the object (code point) Object data Object data is either SCALAR or COLLECTION data. Scalar data consists of a string of bytes formatted as the class description of the object required. Collections consist of a set of objects in which the entries in the collection are nested within the length/ code point of the collection.
Layer B objects with data >=32763 bytes long format is 2 bytes Length - length of class, length, and extended total length fields (high order bit set, indicating >=32763) 2 bytes Type of the object (code point) n bytes Extended total length - length of the object (n = Length - 4) Object data
At layer C are services each class of DDM object provides. |-------------------------------------------| Layer C | Specific | Specific | Specific | | Commands | Replies | Scalars and | | and their | and their | Collections | |-------------------------------------------|----------------| Layer B | Commands | Reply | Scalars and | Communications | | | Messages | Collections | | |-----------|---------------|---------------|----------------| Layer A | RQSDSS | RPYDSS | OBJDSS | CMNDSS | | | | | Mapped Data | |-----------|---------------|---------------|----------------| | DDM Data Stream Structures | |------------------------------------------------------------| DSS's may be chained so that more than one can be transmitted at a time to improve performance. For more details, see DRDA Volume 3 (Distributed Data Management(DDM) Architecture (DDS definition)
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanADJUST_LENGTHSprivate DRDAConnThreadagentprivate byte[]bufferprivate CcsidManagerccsidManagerprivate intcountprivate long[]ddmCollectionLenStackprivate longddmScalarLenprivate static intDEFAULT_BUFFER_SIZEprivate booleandoingLayerBStreamingprivate intdssCorrelationIDprivate booleandssIsChainedWithDiffIDprivate booleandssIsChainedWithSameIDprivate booleandssIsContinuedprivate intdssLengthprivate DssTracedssTraceprivate EbcdicCcsidManagerebcdicCcsidManagerprivate static intEMPTY_STACKprivate java.io.InputStreaminputStreamprivate static longMAX_EXTDTA_SIZEprivate static intMAX_MARKS_NESTINGprivate static booleanNO_ADJUST_LENGTHSprivate static intNO_CODEPOINTprivate intposprivate intprevCorrelationIDprivate intsvrcodprivate static int[][]tenRadixMagnitudeprivate booleanterminateChainOnErrprivate inttopDdmCollectionStack(package private) longtotalByteCountprivate Utf8CcsidManagerutf8CcsidManager
-
Constructor Summary
Constructors Constructor Description DDMReader(java.io.InputStream inputStream)This constructor is used for testing the protocol It is used by ProtocolTestAdapter to read the protocol returned by the serverDDMReader(DRDAConnThread agent, DssTrace dssTrace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidadjustLengths(int length)Adjust remaining lengthprotected voidclearBuffer()private voidcompressBLayerData(int continueDssHeaderCount)Compress B Layer data if extended total length is used by removing the continuation headersprivate int[]computeMagnitude(int[] input)Compute the int array of magnitude from input value segments.protected java.lang.StringconvertBytes(byte[] buf)Convert EBCDIC byte array to unicode string(package private) booleandoingLayerBStreaming()private voidensureALayerDataInBuffer(int desiredDataSize)Make sure a certain amount of Layer A data is in the buffer.private voidensureBLayerDataInBuffer(int desiredDataSize, boolean adjustLen)Make sure a certain amount of Layer B data is in the buffer.private voidensureSpaceInBufferForFill(int desiredSpace)This method makes sure there is enough room in the buffer for a certain number of bytes.private voidfill(int minimumBytesNeeded)This method will attempt to read a minimum number of bytes from the underlying stream.private voidfinishLayerBStreaming()protected intgetCodePoint()Get the next CodePoint from a collectionprotected intgetCodePoint(int codePointCheck)Get the next CodePoint from a collection and check that it matches the specified CodePointprotected bytegetCurrChainState()Return chaining bit for current DSS.protected longgetDdmLength()Length of current DDM object(package private) byte[]getExtData(long desiredLength, boolean checkNullability)(package private) EXTDTAReaderInputStreamgetEXTDTAReaderInputStream(boolean checkNullability)Creates an InputStream which can stream EXTDTA objects.protected voidinitialize(DRDAConnThread agent, DssTrace dssTrace)Initialize values for this session, the reader is reused so we need to set null and 0 valuesprotected booleanisChainedWithDiffID()Next DSS has different correlator than current DSSprotected booleanisChainedWithSameID()Next DSS has same correlator as current DSSprotected booleanisCmd()Check for the command protocolprivate booleanisEXTDTANull()protected voidmarkCollection()Push DDM Length on to collection stackprotected booleanmoreData()Is there more data in the bufferprotected booleanmoreDdmData()Is there more in this DDM objectprotected booleanmoreDssData()Is there more in this DDS objectprivate intpackedNybblesToInt(byte[] buffer, int offset, int startNybble, int numberOfNybbles)Convert a range of packed nybbles (up to 9 digits without overflow) to an int.private longpackedNybblesToLong(byte[] buffer, int offset, int startNybble, int numberOfNybbles)Convert a range of packed nybbles (up to 18 digits without overflow) to a long.protected java.math.BigDecimalreadBigDecimal(int precision, int scale)Read a BigDecimal valueprotected bytereadByte()Read byte valueprotected byte[]readBytes()Read byte string valueprotected byte[]readBytes(int length)Read byte string valueprotected java.lang.StringreadCmdString()Read string valueprotected java.lang.StringreadCmdString(int length)Read string valueprotected intreadCodePoint()Read the CodePointprotected doublereadDouble(int byteOrder)Read platform double valueprivate voidreadDSSContinuationHeader()protected intreadDssHeader()Read DSS header DSS Header format is 2 bytes - length 1 byte - 'D0' - indicates DDM data 1 byte - DSS format |---|---------|----------| | 0 | flags | type | |---|---------|----------| | 0 | 1 2 3 | 4 5 6 7 | |---|---------|----------| bit 0 - '0' bit 1 - '0' - unchained, '1' - chained bit 2 - '0' - do not continue on error, '1' - continue on error bit 3 - '0' - next DSS has different correlator, '1' - next DSS has same correlator type - 1 - Request DSS - 2 - Reply DSS - 3 - Object DSS - 4 - Communications DSS - 5 - Request DSS where no reply is expected 2 bytes - request correlation idprotected java.lang.StringreadEncryptedString(DecryptionManager decryptM, int securityMechanism, byte[] initVector, byte[] sourcePublicKey)Read encrypted stringprotected floatreadFloat(int byteOrder)Read platform float valueprotected intreadInt(int byteOrder)Read platform int valueprotected java.lang.StringreadLDStringData(java.lang.String encoding)Read length delimited string value in DDM data with default encodingprotected intreadLengthAndCodePoint(boolean isLayerBStreamingPossible)Read the DDM Length and CodePointprivate java.io.ByteArrayInputStreamreadLOBChunk(boolean readHeader, long desiredLength)This method is used by EXTDTAReaderInputStream to read the next chunk of data.(package private) java.io.ByteArrayInputStreamreadLOBContinuationStream()This method is used by EXTDTAReaderInputStream to read the next chunk of data.(package private) java.io.ByteArrayInputStreamreadLOBContinuationStream(long desiredLength)This method is used by EXTDTAReaderInputStream to read the next chunk of data.(package private) java.io.ByteArrayInputStreamreadLOBInitStream()This method is used by EXTDTAReaderInputStream to read the first chunk of data.(package private) java.io.ByteArrayInputStreamreadLOBInitStream(long desiredLength)This method is used by EXTDTAReaderInputStream to read the first chunk of data.protected longreadLong(int byteOrder)Read platform long valueprotected intreadNetworkInt()Read network int valueprotected longreadNetworkLong()Read network long valueprotected intreadNetworkShort()Read network short valueprotected longreadNetworkSixByteLong()Read network six byte value and put it in a long vprotected voidreadReplyDss()Read Reply DSS This is used in testing the protocol.protected shortreadShort(int byteOrder)Read platform short valueprotected intreadSignedNetworkShort()Read signed network short valueprotected java.lang.StringreadString()Read string valueprotected java.lang.StringreadString(int length)Read string value Strings in DRDA protocol are encoded in EBCDIC by default so we need to convert to UCS2protected java.lang.StringreadString(int length, java.lang.String encoding)Read encoded string valueprotected voidreadString(DRDAString dst, int size, boolean unpad)Read string value into aDRDAStringobject.protected java.lang.StringreadStringData(int length)Read specified length of string value in DDM data with default encodingprotected intreadUnsignedByte()Read byte value and mask out high order bytes before returningprotected voidsetEbcdicCcsid()protected voidsetUtf8Ccsid()private voidshiftBuffer(byte[] destinationBuffer)This is a helper method which shifts the buffered bytes from wherever they are in the current buffer to the beginning of different buffer (note these buffers could be the same).protected voidskipBytes()Skip byte string valueprotected voidskipBytes(int length)Skip byte string valueprotected voidskipDss()Skip remaining DSSprivate voidstartLayerBStreaming()protected booleanterminateChainOnErr()private voidtrace(java.lang.String msg)Print a internal trace message
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MAX_MARKS_NESTING
private static final int MAX_MARKS_NESTING
- See Also:
- Constant Field Values
-
NO_CODEPOINT
private static final int NO_CODEPOINT
- See Also:
- Constant Field Values
-
EMPTY_STACK
private static final int EMPTY_STACK
- See Also:
- Constant Field Values
-
ADJUST_LENGTHS
private static final boolean ADJUST_LENGTHS
- See Also:
- Constant Field Values
-
NO_ADJUST_LENGTHS
private static final boolean NO_ADJUST_LENGTHS
- See Also:
- Constant Field Values
-
MAX_EXTDTA_SIZE
private static final long MAX_EXTDTA_SIZE
- See Also:
- Constant Field Values
-
tenRadixMagnitude
private static final int[][] tenRadixMagnitude
-
agent
private DRDAConnThread agent
-
utf8CcsidManager
private Utf8CcsidManager utf8CcsidManager
-
ebcdicCcsidManager
private EbcdicCcsidManager ebcdicCcsidManager
-
ccsidManager
private CcsidManager ccsidManager
-
buffer
private byte[] buffer
-
pos
private int pos
-
count
private int count
-
topDdmCollectionStack
private int topDdmCollectionStack
-
ddmCollectionLenStack
private long[] ddmCollectionLenStack
-
ddmScalarLen
private long ddmScalarLen
-
dssLength
private int dssLength
-
dssIsContinued
private boolean dssIsContinued
-
terminateChainOnErr
private boolean terminateChainOnErr
-
dssIsChainedWithSameID
private boolean dssIsChainedWithSameID
-
dssIsChainedWithDiffID
private boolean dssIsChainedWithDiffID
-
dssCorrelationID
private int dssCorrelationID
-
prevCorrelationID
private int prevCorrelationID
-
svrcod
private int svrcod
-
dssTrace
private DssTrace dssTrace
-
inputStream
private java.io.InputStream inputStream
-
doingLayerBStreaming
private boolean doingLayerBStreaming
-
totalByteCount
volatile long totalByteCount
-
-
Constructor Detail
-
DDMReader
DDMReader(DRDAConnThread agent, DssTrace dssTrace)
-
DDMReader
DDMReader(java.io.InputStream inputStream)
This constructor is used for testing the protocol It is used by ProtocolTestAdapter to read the protocol returned by the server
-
-
Method Detail
-
initialize
protected void initialize(DRDAConnThread agent, DssTrace dssTrace)
Initialize values for this session, the reader is reused so we need to set null and 0 values
-
setUtf8Ccsid
protected void setUtf8Ccsid()
-
setEbcdicCcsid
protected void setEbcdicCcsid()
-
terminateChainOnErr
protected boolean terminateChainOnErr()
-
isChainedWithSameID
protected boolean isChainedWithSameID()
Next DSS has same correlator as current DSS- Returns:
- true if next DSS has the same correlator as current DSS
-
isChainedWithDiffID
protected boolean isChainedWithDiffID()
Next DSS has different correlator than current DSS- Returns:
- true if next DSS has a different correlator than current DSS
-
getDdmLength
protected long getDdmLength()
Length of current DDM object- Returns:
- length of DDM object
-
moreDdmData
protected boolean moreDdmData()
Is there more in this DDM object- Returns:
- true if DDM length is > 0
-
moreDssData
protected boolean moreDssData()
Is there more in this DDS object- Returns:
- true if DDS length is > 0
-
moreData
protected boolean moreData()
Is there more data in the buffer- Returns:
- true if there is more data in the buffer
-
isCmd
protected boolean isCmd() throws DRDAProtocolException, java.io.UnsupportedEncodingExceptionCheck for the command protocol- Returns:
- true if this is a command; false otherwise
- Throws:
DRDAProtocolException- if a protocol error is detectedjava.io.UnsupportedEncodingException
-
readDssHeader
protected int readDssHeader() throws DRDAProtocolExceptionRead DSS header DSS Header format is 2 bytes - length 1 byte - 'D0' - indicates DDM data 1 byte - DSS format |---|---------|----------| | 0 | flags | type | |---|---------|----------| | 0 | 1 2 3 | 4 5 6 7 | |---|---------|----------| bit 0 - '0' bit 1 - '0' - unchained, '1' - chained bit 2 - '0' - do not continue on error, '1' - continue on error bit 3 - '0' - next DSS has different correlator, '1' - next DSS has same correlator type - 1 - Request DSS - 2 - Reply DSS - 3 - Object DSS - 4 - Communications DSS - 5 - Request DSS where no reply is expected 2 bytes - request correlation id- Throws:
DRDAProtocolException- if a protocol error is detected
-
readReplyDss
protected void readReplyDss() throws DRDAProtocolExceptionRead Reply DSS This is used in testing the protocol. We shouldn't see a reply DSS when we are servicing DRDA commands- Throws:
DRDAProtocolException- if a protocol error is detected
-
readLengthAndCodePoint
protected int readLengthAndCodePoint(boolean isLayerBStreamingPossible) throws DRDAProtocolExceptionRead the DDM Length and CodePoint- Parameters:
isLayerBStreamingPossible- true only when layer B streaming is possible- Returns:
- - returns codepoint
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readCodePoint
protected int readCodePoint()
Read the CodePoint- Returns:
- - returns codepoint
-
markCollection
protected void markCollection()
Push DDM Length on to collection stack
-
getCodePoint
protected int getCodePoint() throws DRDAProtocolExceptionGet the next CodePoint from a collection- Returns:
- NO_CODEPOINT if collection stack is empty or remaining length is 0; otherwise, read length and code point
- Throws:
DRDAProtocolException- if a protocol error is detected
-
getCodePoint
protected int getCodePoint(int codePointCheck) throws DRDAProtocolExceptionGet the next CodePoint from a collection and check that it matches the specified CodePoint- Parameters:
codePointCheck- - codePoint to check against- Returns:
- codePoint
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readByte
protected byte readByte() throws DRDAProtocolExceptionRead byte value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readUnsignedByte
protected int readUnsignedByte() throws DRDAProtocolExceptionRead byte value and mask out high order bytes before returning- Returns:
- value
- Throws:
DRDAProtocolException
-
readNetworkShort
protected int readNetworkShort() throws DRDAProtocolExceptionRead network short value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readSignedNetworkShort
protected int readSignedNetworkShort() throws DRDAProtocolExceptionRead signed network short value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readShort
protected short readShort(int byteOrder) throws DRDAProtocolExceptionRead platform short value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readNetworkInt
protected int readNetworkInt() throws DRDAProtocolExceptionRead network int value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readInt
protected int readInt(int byteOrder) throws DRDAProtocolExceptionRead platform int value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readNetworkLong
protected long readNetworkLong() throws DRDAProtocolExceptionRead network long value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readNetworkSixByteLong
protected long readNetworkSixByteLong() throws DRDAProtocolExceptionRead network six byte value and put it in a long v- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readLong
protected long readLong(int byteOrder) throws DRDAProtocolExceptionRead platform long value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readFloat
protected float readFloat(int byteOrder) throws DRDAProtocolExceptionRead platform float value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readDouble
protected double readDouble(int byteOrder) throws DRDAProtocolExceptionRead platform double value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readBigDecimal
protected java.math.BigDecimal readBigDecimal(int precision, int scale) throws DRDAProtocolExceptionRead a BigDecimal value- Parameters:
precision- of the BigDecimalscale- of the BigDecimal- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
getEXTDTAReaderInputStream
EXTDTAReaderInputStream getEXTDTAReaderInputStream(boolean checkNullability) throws DRDAProtocolException
Creates an InputStream which can stream EXTDTA objects. The InputStream uses this DDMReader to read data from network. The DDMReader should not be used before all data in the stream has been read.- Parameters:
checkNullability- used to check if the stream is null. If it is null, this method returns null- Returns:
- EXTDTAReaderInputStream object which can be passed to prepared statement as a binary stream.
- Throws:
DRDAProtocolException- standard DRDA protocol exception
-
readLOBInitStream
java.io.ByteArrayInputStream readLOBInitStream() throws DRDAProtocolExceptionThis method is used by EXTDTAReaderInputStream to read the first chunk of data. This lengthless method must be called only when layer B streaming.- Throws:
DRDAProtocolException- standard DRDA protocol exception
-
readLOBInitStream
java.io.ByteArrayInputStream readLOBInitStream(long desiredLength) throws DRDAProtocolExceptionThis method is used by EXTDTAReaderInputStream to read the first chunk of data.- Parameters:
desiredLength- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.- Throws:
DRDAProtocolException- standard DRDA protocol exception
-
readLOBContinuationStream
java.io.ByteArrayInputStream readLOBContinuationStream() throws java.io.IOExceptionThis method is used by EXTDTAReaderInputStream to read the next chunk of data. Calling this method finishes layer B streaming if continuation of DSS segment was finished. This lengthless method must be called only when layer B streaming.- Throws:
java.io.IOException- IOException
-
readLOBContinuationStream
java.io.ByteArrayInputStream readLOBContinuationStream(long desiredLength) throws java.io.IOExceptionThis method is used by EXTDTAReaderInputStream to read the next chunk of data. Furthermore, when Layer B streaming is carried out, calling this method finishes layer B streaming if continuation of DSS segment was finished.- Parameters:
desiredLength- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.- Throws:
java.io.IOException- IOException
-
readLOBChunk
private java.io.ByteArrayInputStream readLOBChunk(boolean readHeader, long desiredLength) throws DRDAProtocolExceptionThis method is used by EXTDTAReaderInputStream to read the next chunk of data. Furthermore, when Layer B streaming is carried out, calling this method may finish layer B streaming.- Parameters:
readHeader- set to true if the dss continuation should be readdesiredLength- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.- Throws:
DRDAProtocolException- standard DRDA protocol exception
-
getExtData
byte[] getExtData(long desiredLength, boolean checkNullability) throws DRDAProtocolException- Throws:
DRDAProtocolException
-
readDSSContinuationHeader
private void readDSSContinuationHeader() throws DRDAProtocolException- Throws:
DRDAProtocolException
-
isEXTDTANull
private boolean isEXTDTANull() throws DRDAProtocolException- Throws:
DRDAProtocolException
-
packedNybblesToInt
private int packedNybblesToInt(byte[] buffer, int offset, int startNybble, int numberOfNybbles)Convert a range of packed nybbles (up to 9 digits without overflow) to an int. Note that for performance purpose, it does not do array-out-of-bound checking.- Parameters:
buffer- buffer to read fromoffset- offset in the bufferstartNybble- start nybblenumberOfNybbles- number of nybbles- Returns:
- an int value
-
packedNybblesToLong
private long packedNybblesToLong(byte[] buffer, int offset, int startNybble, int numberOfNybbles)Convert a range of packed nybbles (up to 18 digits without overflow) to a long. Note that for performance purpose, it does not do array-out-of-bound checking.- Parameters:
buffer- buffer to read fromoffset- offset in the bufferstartNybble- start nybblenumberOfNybbles- number of nybbles- Returns:
- an long value
-
computeMagnitude
private int[] computeMagnitude(int[] input)
Compute the int array of magnitude from input value segments.- Parameters:
input- value segments- Returns:
- array of int magnitudes
-
readEncryptedString
protected java.lang.String readEncryptedString(DecryptionManager decryptM, int securityMechanism, byte[] initVector, byte[] sourcePublicKey) throws DRDAProtocolException, java.sql.SQLException
Read encrypted string- Parameters:
decryptM- decryption managersecurityMechanism- security mechanisminitVector- initialization vector for ciphersourcePublicKey- public key (as in Deffie-Hellman algorithm) from source (encryptor)- Returns:
- decrypted string
- Throws:
DRDAProtocolException- if a protocol error is detectedjava.sql.SQLException- wrapping any exception in decryption
-
readString
protected java.lang.String readString(int length) throws DRDAProtocolExceptionRead string value Strings in DRDA protocol are encoded in EBCDIC by default so we need to convert to UCS2- Parameters:
length- - length of string to read- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readString
protected void readString(DRDAString dst, int size, boolean unpad) throws DRDAProtocolException
Read string value into aDRDAStringobject.- Parameters:
dst- destination for the read stringsize- size (in bytes) of string to readunpad- if true, remove padding (trailing spaces)- Throws:
DRDAProtocolException
-
readString
protected java.lang.String readString(int length, java.lang.String encoding) throws DRDAProtocolExceptionRead encoded string value- Parameters:
length- - length of string to read- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readStringData
protected java.lang.String readStringData(int length) throws DRDAProtocolExceptionRead specified length of string value in DDM data with default encoding- Parameters:
length- - length of string to read- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readLDStringData
protected java.lang.String readLDStringData(java.lang.String encoding) throws DRDAProtocolExceptionRead length delimited string value in DDM data with default encoding- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readString
protected java.lang.String readString() throws DRDAProtocolExceptionRead string value- Throws:
DRDAProtocolException- if a protocol error is detected
-
readBytes
protected byte[] readBytes(int length) throws DRDAProtocolExceptionRead byte string value- Parameters:
length- - length of string to read- Returns:
- byte array
- Throws:
DRDAProtocolException- if a protocol error is detected
-
readBytes
protected byte[] readBytes() throws DRDAProtocolExceptionRead byte string value- Returns:
- byte array
- Throws:
DRDAProtocolException- if a protocol error is detected
-
skipBytes
protected void skipBytes(int length) throws DRDAProtocolExceptionSkip byte string value- Parameters:
length- - length of string to skip- Throws:
DRDAProtocolException- if a protocol error is detected
-
skipBytes
protected void skipBytes() throws DRDAProtocolExceptionSkip byte string value- Throws:
DRDAProtocolException
-
skipDss
protected void skipDss() throws DRDAProtocolExceptionSkip remaining DSS- Throws:
DRDAProtocolException
-
clearBuffer
protected void clearBuffer() throws DRDAProtocolException- Throws:
DRDAProtocolException
-
convertBytes
protected java.lang.String convertBytes(byte[] buf)
Convert EBCDIC byte array to unicode string- Parameters:
buf- - byte array- Returns:
- string
-
adjustLengths
private void adjustLengths(int length)
Adjust remaining length- Parameters:
length- - adjustment length
-
readCmdString
protected java.lang.String readCmdString(int length) throws DRDAProtocolException, java.io.UnsupportedEncodingExceptionRead string value- Parameters:
length- - length of string to read- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detectedjava.io.UnsupportedEncodingException
-
readCmdString
protected java.lang.String readCmdString() throws DRDAProtocolException, java.io.UnsupportedEncodingExceptionRead string value- Returns:
- value
- Throws:
DRDAProtocolException- if a protocol error is detectedjava.io.UnsupportedEncodingException
-
ensureALayerDataInBuffer
private void ensureALayerDataInBuffer(int desiredDataSize) throws DRDAProtocolExceptionMake sure a certain amount of Layer A data is in the buffer. The data will be in the buffer after this method is called.- Parameters:
desiredDataSize- - amount of data we need- Throws:
DRDAProtocolException
-
ensureBLayerDataInBuffer
private void ensureBLayerDataInBuffer(int desiredDataSize, boolean adjustLen) throws DRDAProtocolExceptionMake sure a certain amount of Layer B data is in the buffer. The data will be in the buffer after this method is called.- Parameters:
desiredDataSize- - amount of data we needadjustLen- - whether to adjust the remaining lengths- Throws:
DRDAProtocolException- if a protocol error is detected
-
compressBLayerData
private void compressBLayerData(int continueDssHeaderCount) throws DRDAProtocolExceptionCompress B Layer data if extended total length is used by removing the continuation headers- Parameters:
continueDssHeaderCount- - amount of data we need- Throws:
DRDAProtocolException
-
shiftBuffer
private void shiftBuffer(byte[] destinationBuffer)
This is a helper method which shifts the buffered bytes from wherever they are in the current buffer to the beginning of different buffer (note these buffers could be the same). State information is updated as needed after the shift.- Parameters:
destinationBuffer- - buffer to shift data to
-
ensureSpaceInBufferForFill
private void ensureSpaceInBufferForFill(int desiredSpace)
This method makes sure there is enough room in the buffer for a certain number of bytes. This method will allocate a new buffer if needed and shift the bytes in the current buffer to make ensure space is available for a fill. Right now this method will shift bytes as needed to make sure there is as much room as possible in the buffer before trying to do the read. The idea is to try to have space to get as much data as possible if we need to do a read on the socket's stream.- Parameters:
desiredSpace- - amount of data we need
-
fill
private void fill(int minimumBytesNeeded) throws DRDAProtocolExceptionThis method will attempt to read a minimum number of bytes from the underlying stream. This method will keep trying to read bytes until it has obtained at least the minimum number.- Parameters:
minimumBytesNeeded- - minimum required bytes- Throws:
DRDAProtocolException- if a protocol error is detected
-
trace
private void trace(java.lang.String msg)
Print a internal trace message
-
getCurrChainState
protected byte getCurrChainState()
Return chaining bit for current DSS.
-
startLayerBStreaming
private void startLayerBStreaming()
-
finishLayerBStreaming
private void finishLayerBStreaming()
-
doingLayerBStreaming
boolean doingLayerBStreaming()
-
-