KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > result > Row


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.result;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.store.DataPage;
10 import org.h2.store.Record;
11 import org.h2.value.Value;
12
13 /**
14  * @author Thomas
15  */

16 public class Row extends Record implements SearchRow {
17     private Value[] data;
18
19     public Row(Value[] data) {
20         this.data = data;
21     }
22
23     public Row(Row old) {
24         this.data = old.data;
25     }
26
27     public Row() {
28         // empty constructor
29
}
30
31     public Value getValue(int i) {
32         return data[i];
33     }
34
35     public void write(DataPage buff) throws SQLException JavaDoc {
36         buff.writeInt(data.length);
37         for (int i = 0; i < data.length; i++) {
38             Value v = data[i];
39             buff.writeValue(v);
40         }
41     }
42
43     public int getByteCount(DataPage dummy) throws SQLException JavaDoc {
44         int len = data.length;
45         int size = dummy.getIntLen();
46         for (int i = 0; i < len; i++) {
47             Value v = data[i];
48             size += dummy.getValueLen(v);
49         }
50         return size;
51     }
52
53     public void setValue(int i, Value v) {
54         data[i] = v;
55     }
56
57     public boolean isEmpty() {
58         return data == null;
59     }
60
61     public int getColumnCount() {
62         return data.length;
63     }
64
65 }
66
Popular Tags