KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > index > RangeCursor


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.index;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.message.Message;
10 import org.h2.result.Row;
11 import org.h2.value.Value;
12 import org.h2.value.ValueLong;
13
14 public class RangeCursor implements Cursor {
15
16     private boolean beforeFirst;
17     private long current;
18     private Row currentRow;
19     private long min, max;
20     
21     RangeCursor(long min, long max) {
22         this.min = min;
23         this.max = max;
24         beforeFirst = true;
25     }
26     
27     public Row get() {
28         return currentRow;
29     }
30
31     public int getPos() {
32         throw Message.getInternalError();
33     }
34
35     public boolean next() throws SQLException JavaDoc {
36         if(beforeFirst) {
37             beforeFirst = false;
38             current = min;
39         } else {
40             current++;
41         }
42         currentRow = new Row(new Value[]{ValueLong.get(current)});
43         return current <= max;
44     }
45
46 }
47
Popular Tags