Debian Codegraph @

src/main/org/h2/result/FetchedResult.java

raw
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.result;
7
8 import org.h2.engine.Session;
9 import org.h2.value.Value;
10
11 /**
12 * Abstract fetched result.
13 */
14 public abstract class FetchedResult implements ResultInterface {
15
16 long rowId = -1;
17
18 Value[] currentRow;
19
20 Value[] nextRow;
21
22 boolean afterLast;
23
24 FetchedResult() {
25 }
26
27 @Override
28 public final Value[] currentRow() {
29 return currentRow;
30 }
31
32 @Override
33 public final boolean next() {
34 if (hasNext()) {
35 rowId++;
36 currentRow = nextRow;
37 nextRow = null;
38 return true;
39 }
40 if (!afterLast) {
41 rowId++;
42 currentRow = null;
43 afterLast = true;
44 }
45 return false;
46 }
47
48 @Override
49 public final boolean isAfterLast() {
50 return afterLast;
51 }
52
53 @Override
54 public final long getRowId() {
55 return rowId;
56 }
57
58 @Override
59 public final boolean needToClose() {
60 return true;
61 }
62
63 @Override
64 public final ResultInterface createShallowCopy(Session targetSession) {
65 // The operation is not supported on fetched result.
66 return null;
67 }
68
69 }