📄 reply.java
字号:
clearedByte.length - 4); } } } } } final int readUnsignedShort() throws org.apache.derby.client.am.DisconnectException { // should we be checking dss lengths and ddmScalarLengths here // if yes, i am not sure this is the correct place if we should be checking ensureBLayerDataInBuffer(2); adjustLengths(2); return ((buffer_[pos_++] & 0xff) << 8) + ((buffer_[pos_++] & 0xff) << 0); } final short readShort() throws org.apache.derby.client.am.DisconnectException { // should we be checking dss lengths and ddmScalarLengths here ensureBLayerDataInBuffer(2); adjustLengths(2); short s = SignedBinary.getShort(buffer_, pos_); pos_ += 2; return s; } final int readInt() throws org.apache.derby.client.am.DisconnectException { // should we be checking dss lengths and ddmScalarLengths here ensureBLayerDataInBuffer(4); adjustLengths(4); int i = SignedBinary.getInt(buffer_, pos_); pos_ += 4; return i; } final void readIntArray(int[] array) throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(array.length * 4); adjustLengths(array.length * 4); for (int i = 0; i < array.length; i++) { array[i] = SignedBinary.getInt(buffer_, pos_); pos_ += 4; } } final long readLong() throws org.apache.derby.client.am.DisconnectException { // should we be checking dss lengths and ddmScalarLengths here ensureBLayerDataInBuffer(8); adjustLengths(8); long l = SignedBinary.getLong(buffer_, pos_); pos_ += 8; return l; } final int[] readUnsignedShortList() throws org.apache.derby.client.am.DisconnectException { int len = ddmScalarLen_; ensureBLayerDataInBuffer(len); adjustLengths(len); int count = len / 2; int[] list = new int[count]; for (int i = 0; i < count; i++) { list[i] = ((buffer_[pos_++] & 0xff) << 8) + ((buffer_[pos_++] & 0xff) << 0); } return list; } final int readUnsignedByte() throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(1); adjustLengths(1); return (buffer_[pos_++] & 0xff); } final byte readByte() throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(1); adjustLengths(1); return (byte) (buffer_[pos_++] & 0xff); } final boolean readBoolean() throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(1); adjustLengths(1); return buffer_[pos_++] != 0; } final String readString(int length) throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(length); adjustLengths(length); String result = ccsidManager_.convertToUCS2(buffer_, pos_, length); pos_ += length; return result; } final String readString(int length, String encoding) throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(length); adjustLengths(length); String s = null; try { s = new String(buffer_, pos_, length, encoding); } catch (java.io.UnsupportedEncodingException e) { agent_.accumulateChainBreakingReadExceptionAndThrow(new org.apache.derby.client.am.DisconnectException(e, agent_, "encoding not supported!!")); } pos_ += length; return s; } final String readString() throws org.apache.derby.client.am.DisconnectException { int len = ddmScalarLen_; ensureBLayerDataInBuffer(len); adjustLengths(len); String result = ccsidManager_.convertToUCS2(buffer_, pos_, len); pos_ += len; return result; } final byte[] readBytes(int length) throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(length); adjustLengths(length); byte[] b = new byte[length]; System.arraycopy(buffer_, pos_, b, 0, length); pos_ += length; return b; } final byte[] readBytes() throws org.apache.derby.client.am.DisconnectException { int len = ddmScalarLen_; ensureBLayerDataInBuffer(len); adjustLengths(len); byte[] b = new byte[len]; System.arraycopy(buffer_, pos_, b, 0, len); pos_ += len; return b; } final byte[] readLDBytes() throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(2); int len = ((buffer_[pos_++] & 0xff) << 8) + ((buffer_[pos_++] & 0xff) << 0); if (len == 0) { adjustLengths(2); return null; } ensureBLayerDataInBuffer(len); adjustLengths(len + 2); byte[] b = new byte[len]; System.arraycopy(buffer_, pos_, b, 0, len); pos_ += len; return b; } final void skipBytes(int length) throws org.apache.derby.client.am.DisconnectException { ensureBLayerDataInBuffer(length); adjustLengths(length); pos_ += length; } final void skipBytes() throws org.apache.derby.client.am.DisconnectException { int len = ddmScalarLen_; ensureBLayerDataInBuffer(len); adjustLengths(len); pos_ += len; } // This will be the new and improved getData that handles all QRYDTA/EXTDTA // Returns the stream so that the caller can cache it final ByteArrayOutputStream getData(ByteArrayOutputStream existingBuffer) throws org.apache.derby.client.am.DisconnectException { boolean readHeader; int copySize; ByteArrayOutputStream baos; // note: an empty baos can yield an allocated and empty byte[] if (existingBuffer != null) { baos = existingBuffer; } else { if (ddmScalarLen_ != -1) { // allocate a stream based on a known amount of data baos = new ByteArrayOutputStream(ddmScalarLen_); } else { // allocate a stream to hold an unknown amount of data baos = new ByteArrayOutputStream(); //isLengthAndNullabilityUnknown = true; } } // set the amount to read for the first segment copySize = dssLength_; // note: has already been adjusted for headers do { // determine if a continuation header needs to be read after the data if (dssIsContinued_) { readHeader = true; } else { readHeader = false; } // read the segment ensureALayerDataInBuffer(copySize); adjustLengths(copySize); baos.write(buffer_, pos_, copySize); pos_ += copySize; // read the continuation header, if necessary if (readHeader) { readDSSContinuationHeader(); } copySize = dssLength_; } while (readHeader == true); return baos; } // reads a DSS continuation header // prereq: pos_ is positioned on the first byte of the two-byte header // post: dssIsContinued_ is set to true if the continuation bit is on, false otherwise // dssLength_ is set to DssConstants.MAX_DSS_LEN - 2 (don't count the header for the next read) // helper method for getEXTDTAData protected final void readDSSContinuationHeader() throws org.apache.derby.client.am.DisconnectException { ensureALayerDataInBuffer(2); dssLength_ = ((buffer_[pos_++] & 0xFF) << 8) + ((buffer_[pos_++] & 0xFF) << 0); if ((dssLength_ & 0x8000) == 0x8000) { dssLength_ = DssConstants.MAX_DSS_LEN; dssIsContinued_ = true; } else { dssIsContinued_ = false; } // it is a syntax error if the dss continuation header length // is less than or equal to two if (dssLength_ <= 2) { doSyntaxrmSemantics(CodePoint.SYNERRCD_DSS_CONT_LESS_OR_EQUAL_2); } dssLength_ -= 2; // avoid consuming the DSS cont header } // As part of parsing the reply, the client can detect that the // data sent from the target agent does not structurally // conform to the requirements of the DDM architecture. These are // the same checks performed by the target server on the messages // it receives from the protocolj code. Server side detected errors // result in a SYNTAXRM being returned from the AS. According to the // DDM manual, parsing of the DSS is terminated when the error is // detected. The Syntax Error Code, SYNERRCD, describes the various errors. // // Note: Not all of these may be valid at the client. See descriptions for // which ones make sense for client side errors/checks. // Syntax Error Code Description of Error // ----------------- -------------------- // 0x01 Dss header Length is less than 6. // 0x02 Dss header Length does not match the // number of bytes of data found. // 0x03 Dss header C-byte not D0. // 0x04 Dss header f-bytes either not // recognized or not supported. // 0x05 DSS continuation specified but not found. // For example, DSS continuation is specified // on the last DSS, and the SNA LU 6.2 communication // facility returned the SEND indicator. // 0x06 DSS chaining specified but no DSS found. // For example, DSS chaining is specified // on the last DSS, and the SNA LU 6.2 communication
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -