|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.drda.DDMWriter
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)
Field Summary | |
private DRDAConnThread |
agent
|
private byte[] |
bytes
|
private CcsidManager |
ccsidManager
|
private int |
correlationID
|
private static int |
DEFAULT_BUFFER_SIZE
|
private int |
dssLengthLocation
|
private DssTrace |
dssTrace
|
private boolean |
isContinuationDss
|
private boolean |
isDRDAProtocol
|
private int |
lastDSSBeforeMark
|
private int[] |
markStack
|
private static int |
MAX_MARKS_NESTING
|
private int |
nextCorrelationID
|
private int |
offset
|
private int |
prevHdrLocation
|
private byte |
previousChainByte
|
private int |
previousCorrId
|
private int |
top
|
(package private) static java.math.BigDecimal |
ZERO
|
Constructor Summary | |
(package private) |
DDMWriter(CcsidManager ccsidManager,
DRDAConnThread agent,
DssTrace dssTrace)
|
(package private) |
DDMWriter(int minSize,
CcsidManager ccsidManager,
DRDAConnThread agent,
DssTrace dssTrace)
|
Method Summary | |
private void |
beginDss(boolean chainedToNextStructure,
int dssType)
Begins a DSS stream (for writing LOB data). |
private void |
beginDss(int dssType,
boolean ensureLen)
Write 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 |
private int |
bigDecimalToPackedDecimalBytes(java.math.BigDecimal b,
int precision,
int scale)
Write a Java java.math.BigDecimal to packed decimal bytes. |
private int |
calculateExtendedLengthByteCount(long ddmSize)
Calculate extended length byte count which follows the DSS header for extended DDM. |
protected void |
clearBuffer()
Clear the entire send buffer |
protected void |
clearDdm()
Erase all writes for the current ddm and reset the top |
protected void |
clearDSSesBackToMark(int mark)
Does a logical "clear" of everything written to the buffer after the received mark. |
protected byte[] |
copyDataToEnd(int start)
Copy Data to End Create a buffer and copy from the position given to the end of data |
protected void |
createDssObject()
Create DSS data object |
protected void |
createDssReply()
Create DSS reply object |
protected void |
createDssRequest()
Create DSS request object NOTE: This is _ONLY_ used for testing the protocol (via the TestProto.java file in this package)! |
protected boolean |
doesRequestContainData()
|
protected void |
endDdm()
End the current DDM |
protected void |
endDdmAndDss()
End final DDM and DSS header by writing the length in the length location |
protected void |
endDss()
End DSS header by writing the length in the length location and setting the chain bit. |
private void |
endDss(boolean finalizeLength)
End DSS header by writing the length in the length location and setting the chain bit. |
protected void |
endDss(byte chainByte)
End DSS header by writing the length in the length location and setting the chain bit. |
private void |
ensureLength(int length)
Ensure that there is space in the buffer |
protected void |
finalizeChain(byte currChainByte,
java.io.OutputStream socketOutputStream)
Finalize the current DSS chain and send it if needed. |
private void |
finalizeDssLength()
Finish a DSS Layer A object. |
protected void |
flush()
Flush buffer to outputstream |
protected void |
flush(java.io.OutputStream socketOutputStream)
Flush buffer to specified stream |
protected int |
flushScalarStreamSegment(int leftToRead,
int bytesToRead)
|
private int |
getCorrelationID()
Looks at chaining info for previous DSS written, and use that to figure out what the correlation id for the current DSS should be. |
protected int |
getOffset()
Get offset |
private void |
markDssAsContinued(boolean forLob)
Mark the DSS that we're currently writing as a continued DSS, which is done by setting the high-order bit to "1", per DDM spec. |
protected int |
markDSSClearPoint()
Takes note of the location of the most recently completed DSS in the buffer, and then returns the current offset. |
private static int |
min(int i,
int j)
|
protected void |
padBytes(byte val,
int length)
Write pad bytes using spaceChar |
protected void |
padScalarStreamForError(int leftToRead,
int bytesToRead)
|
protected int |
prepScalarStream(boolean chainedWithSameCorrelator,
int codePoint,
boolean writeNullByte,
int leftToRead)
|
protected void |
reset(DssTrace dssTrace)
reset values for sending next message |
protected void |
resetChainState()
Reset any chaining state that needs to be reset at time of the send |
private void |
sendBytes(java.io.OutputStream socketOutputStream)
|
protected void |
setCMDProtocol()
set protocol to CMD protocol |
protected void |
setOffset(int value)
Set offset |
protected void |
startDdm(int codePoint)
Mark the location of the length bytes for the collection so they can be updated later |
protected void |
startDdm(int length,
int codePoint)
Write length and codepoint |
protected java.lang.String |
toDebugString(java.lang.String indent)
|
protected void |
writeBigDecimal(java.math.BigDecimal v,
int precision,
int scale)
Write big decimal to buffer |
protected void |
writeBoolean(boolean v)
Write platform boolean |
protected void |
writeByte(int value)
Write byte |
protected void |
writeBytes(byte[] buf)
Write byte array |
protected void |
writeBytes(byte[] buf,
int length)
Write byte array |
protected void |
writeBytes(byte[] buf,
int start,
int length)
Write byte array |
(package private) void |
writeCodePoint4Bytes(int codePoint,
int value)
Write code point and 4 bytes |
protected void |
writeDouble(double v)
Write platform double |
protected void |
writeExtendedLength(long size)
|
private void |
writeExtendedLengthBytes(int extendedLengthByteCount,
long length)
|
protected void |
writeFloat(float v)
Write platform float |
protected void |
writeInt(int v)
Write platform int |
protected void |
writeLDBytes(byte[] buf)
|
protected void |
writeLDBytes(byte[] buf,
int index)
|
protected void |
writeLDString(java.lang.String s)
Write length delimited string |
protected void |
writeLDString(java.lang.String s,
int index)
Write length delimited string |
(package private) void |
writeLengthCodePoint(int length,
int codePoint)
|
protected void |
writeLong(long v)
Write platform long |
protected void |
writeNetworkInt(int value)
Write network int |
protected void |
writeNetworkShort(int value)
Write network short |
(package private) void |
writeScalar1Byte(int codePoint,
int value)
Write scalar 1 byte object includes length, codepoint and value |
protected void |
writeScalar2Bytes(int value)
|
protected void |
writeScalar2Bytes(int codePoint,
int value)
Write scalar 2 byte object includes length, codepoint and value |
protected void |
writeScalarBytes(int codePoint,
byte[] buf)
Write scalar byte array object includes length, codepoint and value |
protected void |
writeScalarBytes(int codePoint,
byte[] buf,
int length)
Write scalar byte array object includes length, codepoint and value |
protected void |
writeScalarBytes(int codePoint,
byte[] buf,
int start,
int length)
Write scalar byte array object includes length, codepoint and value |
protected void |
writeScalarHeader(int codePoint,
int dataLength)
Write scalar object header includes length and codepoint |
protected void |
writeScalarPaddedBytes(byte[] buf,
int paddedLength,
byte padByte)
Write padded scalar byte array object value |
protected void |
writeScalarPaddedBytes(int codePoint,
byte[] buf,
int paddedLength,
byte padByte)
Write padded scalar byte array object includes length, codepoint and value |
(package private) void |
writeScalarPaddedString(int codePoint,
java.lang.String string,
int paddedLength)
Write padded scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC) |
protected void |
writeScalarPaddedString(java.lang.String string,
int paddedLength)
Write padded scalar string object value the string is converted into the appropriate codeset (EBCDIC) |
protected int |
writeScalarStream(boolean chainedWithSameCorrelator,
int codePoint,
int length,
java.io.InputStream in,
boolean writeNullByte)
|
(package private) void |
writeScalarString(int codePoint,
java.lang.String string)
Write scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC) |
protected void |
writeShort(boolean b)
Write boolean as short |
protected void |
writeShort(int v)
Write platform short |
protected void |
writeString(java.lang.String s)
Write string with default encoding |
protected void |
writeString(java.lang.String s,
int length)
Write string with default encoding and specified length |
static java.lang.String |
zeroPadString(java.lang.String s,
int precision)
Prepend zeros to numeric string |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int MAX_MARKS_NESTING
private static final int DEFAULT_BUFFER_SIZE
static final java.math.BigDecimal ZERO
private byte[] bytes
private int offset
private int[] markStack
private int top
private CcsidManager ccsidManager
private DRDAConnThread agent
private int dssLengthLocation
private int correlationID
private int nextCorrelationID
private boolean isDRDAProtocol
private DssTrace dssTrace
private int prevHdrLocation
private int previousCorrId
private byte previousChainByte
private boolean isContinuationDss
private int lastDSSBeforeMark
Constructor Detail |
DDMWriter(int minSize, CcsidManager ccsidManager, DRDAConnThread agent, DssTrace dssTrace)
DDMWriter(CcsidManager ccsidManager, DRDAConnThread agent, DssTrace dssTrace)
Method Detail |
protected void reset(DssTrace dssTrace)
protected void setCMDProtocol()
protected void createDssReply()
protected void createDssRequest()
protected void createDssObject()
private void markDssAsContinued(boolean forLob)
protected void endDss(byte chainByte)
protected void endDss()
private void endDss(boolean finalizeLength)
protected void endDdmAndDss()
protected byte[] copyDataToEnd(int start)
start
- protected void startDdm(int codePoint)
protected void clearDdm()
protected void clearBuffer()
protected void endDdm()
protected int getOffset()
protected void setOffset(int value)
value
- new offset valueprotected void writeByte(int value)
value
- byte to be writtenprotected void writeNetworkShort(int value)
value
- value to be writtenprotected void writeNetworkInt(int value)
value
- value to be writtenprotected void writeBytes(byte[] buf, int length)
buf
- byte array to be writtenlength
- - length to writeprotected void writeBytes(byte[] buf, int start, int length)
buf
- byte array to be writtenstart
- - starting positionlength
- - length to writeprotected void writeBytes(byte[] buf)
buf
- byte array to be writtenprotected void writeLDBytes(byte[] buf)
protected void writeLDBytes(byte[] buf, int index)
void writeCodePoint4Bytes(int codePoint, int value)
codePoint
- - code point to writevalue
- - value to write after code pointvoid writeScalar1Byte(int codePoint, int value)
codePoint
- - code point to writevalue
- - value to write after code pointprotected void writeScalar2Bytes(int codePoint, int value)
codePoint
- - code point to writevalue
- - value to write after code pointprotected void writeScalar2Bytes(int value)
protected void startDdm(int length, int codePoint)
length
- - length of objectcodePoint
- - code point to writeprotected void writeScalarBytes(int codePoint, byte[] buf, int length)
codePoint
- - code point to writebuf
- - value to write after code pointlength
- - number of bytes to writeprotected int writeScalarStream(boolean chainedWithSameCorrelator, int codePoint, int length, java.io.InputStream in, boolean writeNullByte) throws DRDAProtocolException
DRDAProtocolException
private void beginDss(boolean chainedToNextStructure, int dssType)
protected int prepScalarStream(boolean chainedWithSameCorrelator, int codePoint, boolean writeNullByte, int leftToRead) throws DRDAProtocolException
DRDAProtocolException
protected boolean doesRequestContainData()
protected int flushScalarStreamSegment(int leftToRead, int bytesToRead) throws DRDAProtocolException
DRDAProtocolException
protected void padScalarStreamForError(int leftToRead, int bytesToRead) throws DRDAProtocolException
DRDAProtocolException
private void writeExtendedLengthBytes(int extendedLengthByteCount, long length)
void writeLengthCodePoint(int length, int codePoint)
protected void writeScalarHeader(int codePoint, int dataLength)
codePoint
- - code point to writedataLength
- - length of object datavoid writeScalarString(int codePoint, java.lang.String string)
codePoint
- - code point to writestring
- - string to be writtenvoid writeScalarPaddedString(int codePoint, java.lang.String string, int paddedLength)
codePoint
- - code point to writestring
- - string to be writtenpaddedLength
- - length to pad string toprotected void writeScalarPaddedString(java.lang.String string, int paddedLength)
string
- - string to be writtenpaddedLength
- - length to pad string toprotected void writeScalarPaddedBytes(int codePoint, byte[] buf, int paddedLength, byte padByte)
codePoint
- - code point to writebuf
- - byte array to be writtenpaddedLength
- - length to pad string topadByte
- - byte to be used for paddingprotected void writeScalarPaddedBytes(byte[] buf, int paddedLength, byte padByte)
buf
- - byte array to be writtenpaddedLength
- - length to pad string topadByte
- - byte to be used for paddingprotected void writeScalarBytes(int codePoint, byte[] buf)
codePoint
- - code point to writebuf
- - byte array to be writtenprotected void writeScalarBytes(int codePoint, byte[] buf, int start, int length)
codePoint
- - code point to writebuf
- - byte array to be writtenstart
- - starting pointlength
- - length to writeprotected void writeShort(int v)
v
- value to be writtenprotected void writeShort(boolean b)
b
- boolean value true = 1 false = 0protected void writeInt(int v)
v
- value to be writtenprotected void writeLong(long v)
v
- value to be writtenprotected void writeFloat(float v)
v
- value to be writtenprotected void writeDouble(double v)
v
- value to be writtenprotected void writeBigDecimal(java.math.BigDecimal v, int precision, int scale) throws java.sql.SQLException
v
- value to writeprecision
- Precison of decimal or numeric type
java.sql.SQLException
- thrown if number of digits > 31protected void writeBoolean(boolean v)
v
- value to be writtenprotected void writeLDString(java.lang.String s) throws DRDAProtocolException
s
- value to be written with integer
DRDAProtocolException
protected void writeLDString(java.lang.String s, int index) throws DRDAProtocolException
s
- value to be written with integerindex
- column index to put in warning
DRDAProtocolException
protected void writeString(java.lang.String s) throws DRDAProtocolException
s
- value to be written
DRDAProtocolException
protected void writeString(java.lang.String s, int length) throws DRDAProtocolException
s
- value to be writtenlength
- number of bytes to be written
DRDAProtocolException
protected void padBytes(byte val, int length)
val
- value to be writtenlength
- length to be writtenprotected void flush() throws java.io.IOException
IOException
protected void flush(java.io.OutputStream socketOutputStream) throws java.io.IOException
socketOutputStream
-
IOException
private void beginDss(int dssType, boolean ensureLen)
private void finalizeDssLength()
protected void writeExtendedLength(long size)
private int calculateExtendedLengthByteCount(long ddmSize)
ddmSize
- - size of DDM command
private void ensureLength(int length)
length
- space requiredprivate int bigDecimalToPackedDecimalBytes(java.math.BigDecimal b, int precision, int scale) throws java.sql.SQLException
java.math.BigDecimal
to packed decimal bytes.
b
- BigDecimal to writeprecision
- Precision of decimal or numeric type
java.sql.SQLException
- Thrown if # digits > 31public static java.lang.String zeroPadString(java.lang.String s, int precision)
s
- stringprecision
- - length of padded string
private void sendBytes(java.io.OutputStream socketOutputStream) throws java.io.IOException
java.io.IOException
private static int min(int i, int j)
protected java.lang.String toDebugString(java.lang.String indent)
protected void resetChainState()
private int getCorrelationID()
protected void finalizeChain(byte currChainByte, java.io.OutputStream socketOutputStream) throws DRDAProtocolException
socketOutputStream
- Output stream to which we're flushing.
DRDAProtocolException
protected int markDSSClearPoint()
protected void clearDSSesBackToMark(int mark)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |