File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\index\RangeCursor.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 import org.h2.value.Value;
13 import org.h2.value.ValueLong;
14
15 /**
16 * The cursor implementation for the range index.
17 */
18 class RangeCursor implements Cursor {
19
20 private boolean beforeFirst;
21 private long current;
22 private Row currentRow;
23 private final long min, max;
24
25 RangeCursor(long min, long max) {
26 this.min = min;
27 this.max = max;
28 beforeFirst = true;
29 }
30
31 public Row get() {
32 return currentRow;
33 }
34
35 public SearchRow getSearchRow() {
36 return currentRow;
37 }
38
39 public boolean next() {
40 if (beforeFirst) {
41 beforeFirst = false;
42 current = min;
43 } else {
44 current++;
45 }
46 currentRow = new Row(new Value[]{ValueLong.get(current)}, 1);
47 return current <= max;
48 }
49
50 public boolean previous() {
51 throw DbException.throwInternalError();
52 }
53
54 }
55