| 1 |
/* |
| 2 |
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (https://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.index; |
| 7 |
|
| 8 |
import org.h2.message.DbException; |
| 9 |
import org.h2.result.Row; |
| 10 |
import org.h2.result.SearchRow; |
| 11 |
import org.h2.value.Value; |
| 12 |
|
| 13 |
/** |
| 14 |
* The cursor implementation for the DUAL index. |
| 15 |
*/ |
| 16 |
class DualCursor implements Cursor { |
| 17 |
|
| 18 |
private Row currentRow; |
| 19 |
|
| 20 |
DualCursor() { |
| 21 |
} |
| 22 |
|
| 23 |
@Override |
| 24 |
public Row get() { |
| 25 |
return currentRow; |
| 26 |
} |
| 27 |
|
| 28 |
@Override |
| 29 |
public SearchRow getSearchRow() { |
| 30 |
return currentRow; |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
public boolean next() { |
| 35 |
if (currentRow == null) { |
| 36 |
currentRow = Row.get(Value.EMPTY_VALUES, 1); |
| 37 |
return true; |
| 38 |
} else { |
| 39 |
return false; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public boolean previous() { |
| 45 |
throw DbException.getInternalError(toString()); |
| 46 |
} |
| 47 |
|
| 48 |
} |