| 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 java.util.ArrayList; |
| 9 |
import org.h2.message.DbException; |
| 10 |
import org.h2.result.Row; |
| 11 |
import org.h2.result.SearchRow; |
| 12 |
|
| 13 |
/** |
| 14 |
* An index for a meta data table. |
| 15 |
* This index can only scan through all rows, search is not supported. |
| 16 |
*/ |
| 17 |
public class MetaCursor implements Cursor { |
| 18 |
|
| 19 |
private Row current; |
| 20 |
private final ArrayList<Row> rows; |
| 21 |
private int index; |
| 22 |
|
| 23 |
MetaCursor(ArrayList<Row> rows) { |
| 24 |
this.rows = rows; |
| 25 |
} |
| 26 |
|
| 27 |
@Override |
| 28 |
public Row get() { |
| 29 |
return current; |
| 30 |
} |
| 31 |
|
| 32 |
@Override |
| 33 |
public SearchRow getSearchRow() { |
| 34 |
return current; |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public boolean next() { |
| 39 |
current = index >= rows.size() ? null : rows.get(index++); |
| 40 |
return current != null; |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public boolean previous() { |
| 45 |
throw DbException.getInternalError(toString()); |
| 46 |
} |
| 47 |
|
| 48 |
} |