File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\index\FunctionCursor.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.ResultInterface;
11 import org.h2.result.Row;
12 import org.h2.result.SearchRow;
13 import org.h2.value.Value;
14
15 /**
16 * A cursor for a function that returns a result.
17 */
18 public class FunctionCursor implements Cursor {
19
20 private final ResultInterface result;
21 private Value[] values;
22 private Row row;
23
24 FunctionCursor(ResultInterface result) {
25 this.result = result;
26 }
27
28 public Row get() {
29 if (values == null) {
30 return null;
31 }
32 if (row == null) {
33 row = new Row(values, 1);
34 }
35 return row;
36 }
37
38 public SearchRow getSearchRow() {
39 return get();
40 }
41
42 public boolean next() {
43 row = null;
44 if (result != null && result.next()) {
45 values = result.currentRow();
46 } else {
47 values = null;
48 }
49 return values != null;
50 }
51
52 public boolean previous() {
53 throw DbException.throwInternalError();
54 }
55
56 }
57