File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\result\SimpleRowValue.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.result;
8
9 import org.h2.engine.Constants;
10 import org.h2.value.Value;
11
12 /**
13 * A simple row that contains data for only one column.
14 */
15 public class SimpleRowValue implements SearchRow {
16
17 private long key;
18 private int version;
19 private int index;
20 private final int virtualColumnCount;
21 private Value data;
22
23 public SimpleRowValue(int columnCount) {
24 this.virtualColumnCount = columnCount;
25 }
26
27 public void setKeyAndVersion(SearchRow row) {
28 key = row.getKey();
29 version = row.getVersion();
30 }
31
32 public int getVersion() {
33 return version;
34 }
35
36 public int getColumnCount() {
37 return virtualColumnCount;
38 }
39
40 public long getKey() {
41 return key;
42 }
43
44 public void setKey(long key) {
45 this.key = key;
46 }
47
48 public Value getValue(int idx) {
49 return idx == index ? data : null;
50 }
51
52 public void setValue(int idx, Value v) {
53 index = idx;
54 data = v;
55 }
56
57 public String toString() {
58 return "( /* " + key + " */ " + (data == null ? "null" : data.getTraceSQL()) + " )";
59 }
60
61 public int getMemory() {
62 return Constants.MEMORY_OBJECT + (data == null ? 0 : data.getMemory());
63 }
64
65 }
66