1 21 22 package org.apache.derby.client.net; 23 24 25 public class NetSqldta extends NetCursor { 26 private NetConnection netConnection_; 27 28 29 public NetSqldta(NetAgent netAgent) { 30 super(netAgent); 31 netConnection_ = netAgent.netConnection_; 32 } 33 34 public boolean next() throws org.apache.derby.client.am.SqlException { 35 if (allRowsReceivedFromServer()) { 36 return false; 37 } else { 38 setAllRowsReceivedFromServer(true); 39 return true; 40 } 41 } 42 43 protected boolean calculateColumnOffsetsForRow() { 44 int colNullIndicator = CodePoint.NULLDATA; 45 int length; 46 47 extdtaPositions_.clear(); 49 if (readFdocaOneByte() == 0xff) { 51 return false; 52 } 53 54 incrementRowsReadEvent(); 55 if (columnDataPosition_ == null || columnDataComputedLength_ == null || isNull_ == null) { 58 allocateColumnOffsetAndLengthArrays(); 59 } 60 61 for (int index = 0; index < columns_; index++) { 63 if (nullable_[index]) 65 68 { 72 colNullIndicator = readFdocaOneByte(); 73 } 74 75 if (!nullable_[index] || (colNullIndicator >= 0 && colNullIndicator <= 127)) { 77 isNull_[index] = false; 78 79 switch (typeToUseForComputingDataLength_[index]) { 80 case Typdef.TWOBYTELENGTH: 83 columnDataPosition_[index] = position_; 84 length = readFdocaTwoByteLength(); 85 if (isGraphic_[index]) { 87 columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 2; 88 } else { 89 columnDataComputedLength_[index] = skipFdocaBytes(length) + 2; 90 } 91 break; 92 93 case Typdef.ONEBYTELENGTH: 96 columnDataPosition_[index] = position_; 97 length = readFdocaOneByte(); 98 if (isGraphic_[index]) { 100 columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 1; 101 } else { 102 columnDataComputedLength_[index] = skipFdocaBytes(length) + 1; 103 } 104 break; 105 106 case Typdef.DECIMALLENGTH: 108 columnDataPosition_[index] = position_; 109 columnDataComputedLength_[index] = skipFdocaBytes(getDecimalLength(index)); 110 break; 111 112 case Typdef.LOBLENGTH: 113 columnDataPosition_[index] = position_; 114 columnDataComputedLength_[index] = this.skipFdocaBytes(fdocaLength_[index] & 0x7fff); 115 break; 116 117 default: 118 columnDataPosition_[index] = position_; 119 if (isGraphic_[index]) { 120 columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index] * 2); 121 } else { 122 columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index]); 123 } 124 break; 125 } 126 } else if ((colNullIndicator & 0x80) == 0x80) { 127 isNull_[index] = true; 129 } 130 } 131 132 if (!allRowsReceivedFromServer()) { 133 calculateLobColumnPositionsForRow(); 134 } 135 136 return true; } 138 139 140 private int skipFdocaBytes(int length) { 141 position_ += length; 142 return length; 143 } 144 145 private int readFdocaOneByte() { 146 return dataBuffer_[position_++] & 0xff; 147 } 148 149 150 private int readFdocaTwoByteLength() { 151 return 152 ((dataBuffer_[position_++] & 0xff) << 8) + 153 ((dataBuffer_[position_++] & 0xff) << 0); 154 } 155 156 157 } 158 159 | Popular Tags |