| java.lang.Object org.apache.derby.impl.drda.DDMWriter
DDMWriter | class DDMWriter (Code) | | The DDMWriter is used to write DRDA protocol. The DRDA Protocol is
described in the DDMReader class.
For more details, see DRDA Volume 3 (Distributed Data Management(DDM)
Architecture (DDS definition)
|
Method Summary | |
protected void | clearBuffer() | protected void | clearDSSesBackToMark(int mark) Does a logical "clear" of everything written to the buffer after
the received mark. | protected void | clearDdm() | protected byte[] | copyDSSDataToEnd(int start) Copy Data to End
Create a buffer and copy from the position given to the end of data
Note that the position given is treated as relative to the
current DSS, for there may be other DSS blocks (chained, presumably)
which are sitting unwritten in the buffer. | protected void | createDssObject() | protected void | createDssReply() | protected void | createDssRequest() Create DSS request object
NOTE: This is _ONLY_ used for testing the protocol
(via the TestProto.java file in this package)!
We should never create a DSS request in normal
DRDA processing (we should only create DSS replies
and DSS objects). | protected boolean | doesRequestContainData() | protected void | endDdm() | protected void | endDdmAndDss() | protected void | endDss(byte chainByte) End DSS header by writing the length in the length location
and setting the chain bit. | protected void | endDss() End DSS header by writing the length in the length location
and setting the chain bit. | protected void | finalizeChain(byte currChainByte, OutputStream socketOutputStream) Finalize the current DSS chain and send it if
needed.
Updates the chaining state of the most recently-written-
to-buffer DSS to correspond to the most recently-read-
from-client request. | protected void | flush() | protected void | flush(OutputStream socketOutputStream) | protected int | getDSSLength() Get the length of the current DSS block we're working on. | protected int | markDSSClearPoint() Takes note of the location of the most recently completed
DSS in the buffer, and then returns the current offset. | protected void | padBytes(byte val, int length) | protected void | reset(DssTrace dssTrace) | protected void | resetChainState() | protected void | setCMDProtocol() | protected void | startDdm(int codePoint) | protected void | startDdm(int length, int codePoint) | protected String | toDebugString(String indent) | protected void | truncateDSS(int value) Truncate the current DSS. | protected void | writeBigDecimal(java.math.BigDecimal v, int precision, int scale) | protected void | writeBoolean(boolean v) | protected void | writeByte(int value) | protected void | writeBytes(byte[] buf, int length) | protected void | writeBytes(byte[] buf, int start, int length) | protected void | writeBytes(byte[] buf) | void | writeCodePoint4Bytes(int codePoint, int value) | protected void | writeDouble(double v) | protected void | writeExtendedLength(long size) | protected void | writeFloat(float v) | protected void | writeInt(int v) | protected void | writeLDBytes(byte[] buf) | protected void | writeLDBytes(byte[] buf, int index) | protected void | writeLDString(String s) | protected void | writeLDString(String s, int index) | void | writeLengthCodePoint(int length, int codePoint) | protected void | writeLong(long v) | protected void | writeNetworkInt(int value) | protected void | writeNetworkShort(int value) | void | writeScalar1Byte(int codePoint, int value) | protected void | writeScalar2Bytes(int codePoint, int value) | protected void | writeScalar2Bytes(int value) | protected void | writeScalarBytes(int codePoint, byte[] buf, int length) | protected void | writeScalarBytes(int codePoint, byte[] buf) | protected void | writeScalarBytes(int codePoint, byte[] buf, int start, int length) | protected void | writeScalarHeader(int codePoint, int dataLength) | protected void | writeScalarPaddedBytes(int codePoint, byte[] buf, int paddedLength, byte padByte) | protected void | writeScalarPaddedBytes(byte[] buf, int paddedLength, byte padByte) | void | writeScalarPaddedString(int codePoint, String string, int paddedLength) | protected void | writeScalarPaddedString(String string, int paddedLength) | protected void | writeScalarPaddedString(DRDAString drdaString, int paddedLength) Write padded scalar DRDAString object value. | protected void | writeScalarStream(boolean chainedWithSameCorrelator, int codePoint, EXTDTAInputStream in, boolean writeNullByte) | void | writeScalarString(int codePoint, String string) | protected void | writeShort(int v) | protected void | writeShort(boolean b) | protected void | writeString(String s) | protected void | writeString(String s, int length) | public static String | zeroPadString(String s, int precision) |
clearBuffer | protected void clearBuffer()(Code) | | Clear the entire send buffer
|
clearDSSesBackToMark | protected void clearDSSesBackToMark(int mark)(Code) | | Does a logical "clear" of everything written to the buffer after
the received mark. It's assumed that this method will be used
in error cases when we've started writing one or more DSSes,
but then hit an error and need to back out. After backing out,
we'll always need to write _something_ back to the client to
indicate an error (typically, we just write an SQLCARD) but what
exactly gets written is handled in DRDAConnThread. Here, we
just do the necessary prep so that whatever comes next will
succeed.
|
clearDdm | protected void clearDdm()(Code) | | Erase all writes for the current ddm and reset the
top
|
copyDSSDataToEnd | protected byte[] copyDSSDataToEnd(int start)(Code) | | Copy Data to End
Create a buffer and copy from the position given to the end of data
Note that the position given is treated as relative to the
current DSS, for there may be other DSS blocks (chained, presumably)
which are sitting unwritten in the buffer. The caller doesn't
know this, though, and works only with the current DSS.
getDSSLength, copyDSSDataToEnd, and truncateDSS work together to
provide a sub-protocol for DRDAConnThread to use in its
implementation of the LMTBLKPRC protocol. They enable the caller
to determine when it has written too much data into the current
DSS, to reclaim the extra data that won't fit, and to truncate
that extra data once it has been reclaimed and stored elsewhere.
Note that this support only works for the current DSS. Earlier,
chained DSS blocks cannot be accessed using these methods. For
additional background information, the interested reader should
investigate bugs DERBY-491 and 492 at:
http://issues.apache.org/jira/browse/DERBY-491 and
http://issues.apache.org/jira/browse/DERBY-492
Parameters: start - |
createDssObject | protected void createDssObject()(Code) | | Create DSS data object
|
createDssReply | protected void createDssReply()(Code) | | Create DSS reply object
|
createDssRequest | protected void createDssRequest()(Code) | | Create DSS request object
NOTE: This is _ONLY_ used for testing the protocol
(via the TestProto.java file in this package)!
We should never create a DSS request in normal
DRDA processing (we should only create DSS replies
and DSS objects).
|
doesRequestContainData | protected boolean doesRequestContainData()(Code) | | |
endDdm | protected void endDdm()(Code) | | End the current DDM
|
endDdmAndDss | protected void endDdmAndDss()(Code) | | End final DDM and DSS header by writing the length in the length location
|
endDss | protected void endDss(byte chainByte)(Code) | | End DSS header by writing the length in the length location
and setting the chain bit. Unlike the other two endDss
methods, this one overrides the default chaining byte
(which is set in beginDss) with the chaining byte that
is passed in. NOTE: This method is only used in
association with createDssRequest, and thus is for
TESTING purposes only (via TestProto.java). No calls
should be made to this method in normal DRDA processing
(because for normal processing, chaining must be
determined automatically based on DSS requests).
|
endDss | protected void endDss()(Code) | | End DSS header by writing the length in the length location
and setting the chain bit.
|
finalizeChain | protected void finalizeChain(byte currChainByte, OutputStream socketOutputStream) throws DRDAProtocolException(Code) | | Finalize the current DSS chain and send it if
needed.
Updates the chaining state of the most recently-written-
to-buffer DSS to correspond to the most recently-read-
from-client request. If that chaining state indicates
we've reached the end of a chain, then we go ahead
and send the buffer across the wire.
Parameters: socketOutputStream - Output stream to which we're flushing. |
getDSSLength | protected int getDSSLength()(Code) | | Get the length of the current DSS block we're working on. This is
used by the LMTBLKPRC protocol, which does its own conversational
blocking protocol above the layer of the DRDA blocking. The LMTBLKPRC
implementation (in DRDAConnThread) needs to be able to truncate a
DSS block when splitting a QRYDTA response.
current DSS block length |
markDSSClearPoint | protected int markDSSClearPoint()(Code) | | Takes note of the location of the most recently completed
DSS in the buffer, and then returns the current offset.
This method is used in conjunction with "clearDSSesBackToMark"
to allow for DRDAConnThread to "back-out" DSSes in the
event of errors.
|
padBytes | protected void padBytes(byte val, int length)(Code) | | Write pad bytes using spaceChar
Parameters: val - value to be written Parameters: length - length to be written |
reset | protected void reset(DssTrace dssTrace)(Code) | | reset values for sending next message
|
resetChainState | protected void resetChainState()(Code) | | Reset any chaining state that needs to be reset
at time of the send
|
setCMDProtocol | protected void setCMDProtocol()(Code) | | set protocol to CMD protocol
|
startDdm | protected void startDdm(int codePoint)(Code) | | Mark the location of the length bytes for the collection so they
can be updated later
|
startDdm | protected void startDdm(int length, int codePoint)(Code) | | Write length and codepoint
Parameters: length - - length of object Parameters: codePoint - - code point to write |
truncateDSS | protected void truncateDSS(int value)(Code) | | Truncate the current DSS. Before making this call, you should ensure
that you have copied the data to be truncated somewhere else, by
calling copyDSSDataToEnd
Parameters: value - DSS length |
writeBigDecimal | protected void writeBigDecimal(java.math.BigDecimal v, int precision, int scale) throws SQLException(Code) | | Write big decimal to buffer
Parameters: v - value to write Parameters: precision - Precison of decimal or numeric type Parameters: scale - declared scale exception: SQLException - thrown if number of digits > 31 |
writeBoolean | protected void writeBoolean(boolean v)(Code) | | Write platform boolean
Parameters: v - value to be written |
writeByte | protected void writeByte(int value)(Code) | | Write byte
Parameters: value - byte to be written |
writeBytes | protected void writeBytes(byte[] buf, int length)(Code) | | Write byte array
Parameters: buf - byte array to be written Parameters: length - - length to write |
writeBytes | protected void writeBytes(byte[] buf, int start, int length)(Code) | | Write byte array
Parameters: buf - byte array to be written Parameters: start - - starting position Parameters: length - - length to write |
writeBytes | protected void writeBytes(byte[] buf)(Code) | | Write byte array
Parameters: buf - byte array to be written |
writeCodePoint4Bytes | void writeCodePoint4Bytes(int codePoint, int value)(Code) | | Write code point and 4 bytes
Parameters: codePoint - - code point to write Parameters: value - - value to write after code point |
writeDouble | protected void writeDouble(double v)(Code) | | Write platform double
Parameters: v - value to be written |
writeExtendedLength | protected void writeExtendedLength(long size)(Code) | | |
writeFloat | protected void writeFloat(float v)(Code) | | Write platform float
Parameters: v - value to be written |
writeInt | protected void writeInt(int v)(Code) | | Write platform int
Parameters: v - value to be written |
writeLDBytes | protected void writeLDBytes(byte[] buf)(Code) | | |
writeLDBytes | protected void writeLDBytes(byte[] buf, int index)(Code) | | |
writeLengthCodePoint | void writeLengthCodePoint(int length, int codePoint)(Code) | | |
writeLong | protected void writeLong(long v)(Code) | | Write platform long
Parameters: v - value to be written |
writeNetworkInt | protected void writeNetworkInt(int value)(Code) | | Write network int
Parameters: value - value to be written |
writeNetworkShort | protected void writeNetworkShort(int value)(Code) | | Write network short
Parameters: value - value to be written |
writeScalar1Byte | void writeScalar1Byte(int codePoint, int value)(Code) | | Write scalar 1 byte object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: value - - value to write after code point |
writeScalar2Bytes | protected void writeScalar2Bytes(int codePoint, int value)(Code) | | Write scalar 2 byte object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: value - - value to write after code point |
writeScalar2Bytes | protected void writeScalar2Bytes(int value)(Code) | | |
writeScalarBytes | protected void writeScalarBytes(int codePoint, byte[] buf, int length)(Code) | | Write scalar byte array object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: buf - - value to write after code point Parameters: length - - number of bytes to write |
writeScalarBytes | protected void writeScalarBytes(int codePoint, byte[] buf)(Code) | | Write scalar byte array object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: buf - - byte array to be written |
writeScalarBytes | protected void writeScalarBytes(int codePoint, byte[] buf, int start, int length)(Code) | | Write scalar byte array object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: buf - - byte array to be written Parameters: start - - starting point Parameters: length - - length to write |
writeScalarHeader | protected void writeScalarHeader(int codePoint, int dataLength)(Code) | | Write scalar object header includes length and codepoint
Parameters: codePoint - - code point to write Parameters: dataLength - - length of object data |
writeScalarPaddedBytes | protected void writeScalarPaddedBytes(int codePoint, byte[] buf, int paddedLength, byte padByte)(Code) | | Write padded scalar byte array object includes length, codepoint and value
Parameters: codePoint - - code point to write Parameters: buf - - byte array to be written Parameters: paddedLength - - length to pad string to Parameters: padByte - - byte to be used for padding |
writeScalarPaddedBytes | protected void writeScalarPaddedBytes(byte[] buf, int paddedLength, byte padByte)(Code) | | Write padded scalar byte array object value
Parameters: buf - - byte array to be written Parameters: paddedLength - - length to pad string to Parameters: padByte - - byte to be used for padding |
writeScalarPaddedString | void writeScalarPaddedString(int codePoint, String string, int paddedLength)(Code) | | Write padded scalar string object includes length, codepoint and value
the string is converted into the appropriate codeset (EBCDIC)
Parameters: codePoint - - code point to write Parameters: string - - string to be written Parameters: paddedLength - - length to pad string to |
writeScalarPaddedString | protected void writeScalarPaddedString(String string, int paddedLength)(Code) | | Write padded scalar string object value
the string is converted into the appropriate codeset (EBCDIC)
Parameters: string - - string to be written Parameters: paddedLength - - length to pad string to |
writeScalarPaddedString | protected void writeScalarPaddedString(DRDAString drdaString, int paddedLength)(Code) | | Write padded scalar DRDAString object value. The
string is converted into the appropriate codeset.
Parameters: drdaString - string to be written Parameters: paddedLength - length to pad string to |
writeScalarString | void writeScalarString(int codePoint, String string)(Code) | | Write scalar string object includes length, codepoint and value
the string is converted into the appropriate codeset (EBCDIC)
Parameters: codePoint - - code point to write Parameters: string - - string to be written |
writeShort | protected void writeShort(int v)(Code) | | Write platform short
Parameters: v - value to be written |
writeShort | protected void writeShort(boolean b)(Code) | | Write boolean as short
Parameters: b - boolean value true = 1 false = 0 |
writeString | protected void writeString(String s, int length) throws DRDAProtocolException(Code) | | Write string with default encoding and specified length
Parameters: s - value to be written Parameters: length - number of bytes to be written exception: DRDAProtocolException - |
zeroPadString | public static String zeroPadString(String s, int precision)(Code) | | Prepend zeros to numeric string
Parameters: s - string Parameters: precision - - length of padded string zero padded string |
|
|