File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\index\SingleRowCursor.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.index;
8
9 import org.h2.message.DbException;
10 import org.h2.result.Row;
11 import org.h2.result.SearchRow;
12
13 /**
14 * A cursor with at most one row.
15 */
16 public class SingleRowCursor implements Cursor {
17 private Row row;
18 private boolean end;
19
20 /**
21 * Create a new cursor.
22 *
23 * @param row - the single row (if null then cursor is empty)
24 */
25 public SingleRowCursor(Row row) {
26 this.row = row;
27 }
28
29 public Row get() {
30 return row;
31 }
32
33 public SearchRow getSearchRow() {
34 return row;
35 }
36
37 public boolean next() {
38 if (row == null || end) {
39 row = null;
40 return false;
41 }
42 end = true;
43 return true;
44 }
45
46 public boolean previous() {
47 throw DbException.throwInternalError();
48 }
49
50 }
51