EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.client.net]

COVERAGE SUMMARY FOR SOURCE FILE [NetSqldta.java]

nameclass, %method, %block, %line, %
NetSqldta.java100% (1/1)83%  (5/6)67%  (194/288)67%  (35/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NetSqldta100% (1/1)83%  (5/6)67%  (194/288)67%  (35/52)
NetSqldta (NetAgent): void 100% (1/1)100% (8/8)100% (3/3)
calculateColumnOffsetsForRow (): boolean 100% (1/1)62%  (135/219)68%  (28/41)
next (): boolean 0%   (0/1)0%   (0/10)0%   (0/4)
readFdocaOneByte (): int 100% (1/1)100% (13/13)100% (1/1)
readFdocaTwoByteLength (): int 100% (1/1)100% (30/30)100% (1/1)
skipFdocaBytes (int): int 100% (1/1)100% (8/8)100% (2/2)

1/*
2 
3   Derby - Class org.apache.derby.client.net.NetSqldta
4 
5   Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19*/
20 
21package org.apache.derby.client.net;
22 
23 
24public class NetSqldta extends NetCursor {
25    private NetConnection netConnection_;
26 
27 
28    public NetSqldta(NetAgent netAgent) {
29        super(netAgent);
30        netConnection_ = netAgent.netConnection_;
31    }
32 
33    public boolean next() throws org.apache.derby.client.am.SqlException {
34        if (allRowsReceivedFromServer()) {
35            return false;
36        } else {
37            setAllRowsReceivedFromServer(true);
38            return true;
39        }
40    }
41 
42    protected boolean calculateColumnOffsetsForRow() {
43        int colNullIndicator = CodePoint.NULLDATA;
44        int length;
45 
46        extdtaPositions_.clear();  // reset positions for this row
47 
48        // read the da null indicator
49        if (readFdocaOneByte() == 0xff) {
50            return false;
51        }
52 
53        incrementRowsReadEvent();
54        // Use the arrays defined on the Cursor for forward-only cursors.
55        // can they ever be null
56        if (columnDataPosition_ == null || columnDataComputedLength_ == null || isNull_ == null) {
57            allocateColumnOffsetAndLengthArrays();
58        }
59 
60        // Loop through the columns
61        for (int index = 0; index < columns_; index++) {
62            // If column is nullable, read the 1-byte null indicator.
63            if (nullable_[index])
64            // Need to pass the column index so all previously calculated offsets can be
65            // readjusted if the query block splits on a column null indicator.
66 
67            // null indicators from FD:OCA data
68            // 0 to 127: a data value will flow.
69            // -1 to -128: no data value will flow.
70            {
71                colNullIndicator = readFdocaOneByte();
72            }
73 
74            // If non-null column data
75            if (!nullable_[index] || (colNullIndicator >= 0 && colNullIndicator <= 127)) {
76                isNull_[index] = false;
77 
78                switch (typeToUseForComputingDataLength_[index]) {
79                // for variable character string and variable byte string,
80                // there are 2-byte of length in front of the data
81                case Typdef.TWOBYTELENGTH:
82                    columnDataPosition_[index] = position_;
83                    length = readFdocaTwoByteLength();
84                    // skip length + the 2-byte length field
85                    if (isGraphic_[index]) {
86                        columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 2;
87                    } else {
88                        columnDataComputedLength_[index] = skipFdocaBytes(length) + 2;
89                    }
90                    break;
91 
92                    // for short variable character string and short variable byte string,
93                    // there is a 1-byte length in front of the data
94                case Typdef.ONEBYTELENGTH:
95                    columnDataPosition_[index] = position_;
96                    length = readFdocaOneByte();
97                    // skip length + the 1-byte length field
98                    if (isGraphic_[index]) {
99                        columnDataComputedLength_[index] = skipFdocaBytes(length * 2) + 1;
100                    } else {
101                        columnDataComputedLength_[index] = skipFdocaBytes(length) + 1;
102                    }
103                    break;
104 
105                    // For decimal columns, determine the precision, scale, and the representation
106                case Typdef.DECIMALLENGTH:
107                    columnDataPosition_[index] = position_;
108                    columnDataComputedLength_[index] = skipFdocaBytes(getDecimalLength(index));
109                    break;
110 
111                case Typdef.LOBLENGTH:
112                    columnDataPosition_[index] = position_;
113                    columnDataComputedLength_[index] = this.skipFdocaBytes(fdocaLength_[index] & 0x7fff);
114                    break;
115 
116                default:
117                    columnDataPosition_[index] = position_;
118                    if (isGraphic_[index]) {
119                        columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index] * 2);
120                    } else {
121                        columnDataComputedLength_[index] = skipFdocaBytes(fdocaLength_[index]);
122                    }
123                    break;
124                }
125            } else if ((colNullIndicator & 0x80) == 0x80) {
126                // Null data. Set the isNull indicator to true.
127                isNull_[index] = true;
128            }
129        }
130 
131        if (!allRowsReceivedFromServer()) {
132            calculateLobColumnPositionsForRow();
133        }
134 
135        return true; // hardwired for now, this means the current row position is a valid position
136    }
137 
138 
139    private int skipFdocaBytes(int length) {
140        position_ += length;
141        return length;
142    }
143 
144    private int readFdocaOneByte() {
145        return dataBuffer_[position_++] & 0xff;
146    }
147 
148 
149    private int readFdocaTwoByteLength() {
150        return
151                ((dataBuffer_[position_++] & 0xff) << 8) +
152                ((dataBuffer_[position_++] & 0xff) << 0);
153    }
154 
155 
156}
157 

[all classes][org.apache.derby.client.net]
EMMA 2.0.5312 (C) Vladimir Roubtsov