Debian Codegraph @

src/main/org/h2/result/ResultInterface.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.TypeInfo;
10 import org.h2.value.Value;
11
12 /**
13 * The result interface is used by the LocalResult and ResultRemote class.
14 * A result may contain rows, or just an update count.
15 */
16 public interface ResultInterface extends AutoCloseable {
17
18 /**
19 * Go to the beginning of the result, that means
20 * before the first row.
21 */
22 void reset();
23
24 /**
25 * Get the current row.
26 *
27 * @return the row
28 */
29 Value[] currentRow();
30
31 /**
32 * Go to the next row.
33 *
34 * @return true if a row exists
35 */
36 boolean next();
37
38 /**
39 * Get the current row id, starting with 0.
40 * -1 is returned when next() was not called yet.
41 *
42 * @return the row id
43 */
44 long getRowId();
45
46 /**
47 * Check if the current position is after last row.
48 *
49 * @return true if after last
50 */
51 boolean isAfterLast();
52
53 /**
54 * Get the number of visible columns.
55 * More columns may exist internally for sorting or grouping.
56 *
57 * @return the number of columns
58 */
59 int getVisibleColumnCount();
60
61 /**
62 * Get the number of rows in this object.
63 *
64 * @return the number of rows
65 */
66 long getRowCount();
67
68 /**
69 * Check if this result has more rows to fetch.
70 *
71 * @return true if it has
72 */
73 boolean hasNext();
74
75 /**
76 * Check if this result set should be closed, for example because it is
77 * buffered using a temporary file.
78 *
79 * @return true if close should be called.
80 */
81 boolean needToClose();
82
83 /**
84 * Close the result and delete any temporary files
85 */
86 @Override
87 void close();
88
89 /**
90 * Get the column alias name for the column.
91 *
92 * @param i the column number (starting with 0)
93 * @return the alias name
94 */
95 String getAlias(int i);
96
97 /**
98 * Get the schema name for the column, if one exists.
99 *
100 * @param i the column number (starting with 0)
101 * @return the schema name or null
102 */
103 String getSchemaName(int i);
104
105 /**
106 * Get the table name for the column, if one exists.
107 *
108 * @param i the column number (starting with 0)
109 * @return the table name or null
110 */
111 String getTableName(int i);
112
113 /**
114 * Get the column name.
115 *
116 * @param i the column number (starting with 0)
117 * @return the column name
118 */
119 String getColumnName(int i);
120
121 /**
122 * Get the column data type.
123 *
124 * @param i the column number (starting with 0)
125 * @return the column data type
126 */
127 TypeInfo getColumnType(int i);
128
129 /**
130 * Check if this is an identity column.
131 *
132 * @param i the column number (starting with 0)
133 * @return true for identity columns
134 */
135 boolean isIdentity(int i);
136
137 /**
138 * Check if this column is nullable.
139 *
140 * @param i the column number (starting with 0)
141 * @return Column.NULLABLE_*
142 */
143 int getNullable(int i);
144
145 /**
146 * Set the fetch size for this result set.
147 *
148 * @param fetchSize the new fetch size
149 */
150 void setFetchSize(int fetchSize);
151
152 /**
153 * Get the current fetch size for this result set.
154 *
155 * @return the fetch size
156 */
157 int getFetchSize();
158
159 /**
160 * Check if this a lazy execution result.
161 *
162 * @return true if it is a lazy result
163 */
164 boolean isLazy();
165
166 /**
167 * Check if this result set is closed.
168 *
169 * @return true if it is
170 */
171 boolean isClosed();
172
173 /**
174 * Create a shallow copy of the result set. The data and a temporary table
175 * (if there is any) is not copied.
176 *
177 * @param targetSession the session of the copy
178 * @return the copy if possible, or null if copying is not possible
179 */
180 ResultInterface createShallowCopy(Session targetSession);
181
182 }