01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.index;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.message.Message;
11: import org.h2.result.LocalResult;
12: import org.h2.result.Row;
13: import org.h2.result.SearchRow;
14:
15: /**
16: * A cursor for a function that returns a result set.
17: */
18: public class FunctionCursor implements Cursor {
19:
20: private LocalResult result;
21: private Row row;
22:
23: FunctionCursor(LocalResult result) {
24: this .result = result;
25: }
26:
27: public Row get() {
28: return row;
29: }
30:
31: public SearchRow getSearchRow() throws SQLException {
32: return row;
33: }
34:
35: public int getPos() {
36: throw Message.getInternalError();
37: }
38:
39: public boolean next() throws SQLException {
40: if (result.next()) {
41: row = new Row(result.currentRow(), 0);
42: } else {
43: row = null;
44: }
45: return row != null;
46: }
47:
48: }
|