-
Notifications
You must be signed in to change notification settings - Fork 14
/
ResultRow.java
310 lines (282 loc) · 14.4 KB
/
ResultRow.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.ontodriver.iteration;
import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
/**
* Represents a single row in a {@link cz.cvut.kbss.ontodriver.ResultSet}.
* <p>
* This interface replicates the value retrieval API of {@code ResultSet} and serves as a view of the current row in a result set.
* <p>
* The main purpose of this interface is to support iteration over result sets.
*/
public interface ResultRow {
/**
* Retrieves index of a column with the specified label.
*
* @param columnLabel Label of the column
* @return index of the column or -1 if there is no such column
* @throws IllegalStateException If called on a closed result set
*/
int findColumn(String columnLabel);
/**
* Gets the count of available columns.
* <p>
* This number corresponds to the number of result variables bound in the query.
*
* @return Number of columns in the result set
* @throws IllegalStateException If called on a closed result set
*/
int getColumnCount();
/**
* Checks whether a value at the specified index is bound in the current result row.
* <p>
* Note that this method will return {@code false} also in case the index is out of range of the variables known to
* the result set as a whole.
*
* @param variableIndex Index of the variable
* @return {@code true} when value is bound in the current row, {@code false} otherwise
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException When unable to resolve binding status
*/
boolean isBound(int variableIndex) throws OntoDriverException;
/**
* Checks whether a value of the specified variable is bound in the current result row.
* <p>
* Note that this method will return {@code false} also in case the variable is not known to the result set at all.
*
* @param variableName Variable name
* @return {@code true} when value is bound in the current row, {@code false} otherwise
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException When unable to resolve binding status
*/
boolean isBound(String variableName) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as a {@code boolean}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code boolean} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code boolean} or there occurs some other error
*/
boolean getBoolean(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as a {@code boolean}.
*
* @param columnLabel Label of the column
* @return {@code boolean} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* boolean} or there occurs some other error
*/
boolean getBoolean(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code byte}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code byte} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code byte} or there occurs some other error
*/
byte getByte(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code byte}.
*
* @param columnLabel Label of the column
* @return {@code byte} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* byte} or there occurs some other error
*/
byte getByte(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code double}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code double} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code double} or there occurs some other error
*/
double getDouble(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code double}.
*
* @param columnLabel Label of the column
* @return {@code double} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* double} or there occurs some other error
*/
double getDouble(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code float}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code float} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code float} or there occurs some other error
*/
float getFloat(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code float}.
*
* @param columnLabel Label of the column
* @return {@code float} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* float} or there occurs some other error
*/
float getFloat(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code int}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code int} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code int} or there occurs some other error
*/
int getInt(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code int}.
*
* @param columnLabel Label of the column
* @return {@code int} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* int} or there occurs some other error
*/
int getInt(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code long}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code long} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code long} or there occurs some other error
*/
long getLong(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code long}.
*
* @param columnLabel Label of the column
* @return {@code long} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* long} or there occurs some other error
*/
long getLong(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as {@code Object}.
*
* @param columnIndex Column index, the first column has index 0
* @return column value cast to {@code Object}
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index or there occurs some other
* error
*/
Object getObject(int columnIndex) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as {@code Object}.
*
* @param columnLabel Label of the column
* @return column value cast to {@code Object}
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label or there occurs some other error
*/
Object getObject(String columnLabel) throws OntoDriverException;
/**
* Retrieves value from column at the specified index and returns it as an instance of the specified class.
* <p>
* The mechanism of transforming the value to the specified class is not specified, it can be merely type casting or
* calling a constructor of the specified type.
*
* @param columnIndex Column index, the first column has index 0
* @param cls Requested class type
* @param <T> Return type
* @return Value of the column
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* the specified type or there occurs some other error
*/
<T> T getObject(int columnIndex, Class<T> cls) throws OntoDriverException;
/**
* Retrieves value from column with the specified label and returns it as an instance of the specified class.
* <p>
* The mechanism of transforming the value to the specified class is not specified, it can be merely type casting or
* calling a constructor of the specified type.
*
* @param columnLabel Label of the column
* @param cls Requested class type
* @param <T> Return type
* @return Value of the column.
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to the
* specified type or there occurs some other error
*/
<T> T getObject(String columnLabel, Class<T> cls) throws OntoDriverException;
/**
* Retrieves value of column at the specified index and returns it as {@code short}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code short} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code short} or there occurs some other error
*/
short getShort(int columnIndex) throws OntoDriverException;
/**
* Retrieves value of column with the specified label and returns it as {@code short}.
*
* @param columnLabel Label of the column
* @return {@code short} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* short} or there occurs some other error
*/
short getShort(String columnLabel) throws OntoDriverException;
/**
* Retrieves value of column at the specified index and returns it as {@code String}.
*
* @param columnIndex Column index, the first column has index 0
* @return {@code String} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If the {@code columnIndex} is not a valid column index, the value cannot be cast to
* {@code String} or there occurs some other error
*/
String getString(int columnIndex) throws OntoDriverException;
/**
* Retrieves value of column with the specified label and returns it as {@code String}.
*
* @param columnLabel Label of the column
* @return {@code String} value
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If there is no column with the specified label, the value cannot be cast to {@code
* String} or there occurs some other error
*/
String getString(String columnLabel) throws OntoDriverException;
/**
* Gets the index of this row (first row has index 0).
*
* @return Index of this row
* @throws IllegalStateException If called on a closed result set
* @throws OntoDriverException If some other error occurs
*/
int getIndex() throws OntoDriverException;
}