KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jdbc > support > rowset > SqlRowSet


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.jdbc.support.rowset;
18
19 import java.io.Serializable JavaDoc;
20 import java.math.BigDecimal JavaDoc;
21 import java.sql.Date JavaDoc;
22 import java.sql.Time JavaDoc;
23 import java.sql.Timestamp JavaDoc;
24 import java.util.Calendar JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import org.springframework.jdbc.InvalidResultSetAccessException;
28
29 /**
30  * Mirror interface for <code>javax.sql.RowSet</code>, representing
31  * disconnected <code>java.sql.ResultSet</code> data.
32  *
33  * <p>The main difference to the standard JDBC RowSet is that an SQLException
34  * is never thrown here. This allows a SqlRowSet to be used without having
35  * to deal with checked exceptions. A SqlRowSet will throw Spring's
36  * <code>org.springframework.jdbc.InvalidResultSetAccessException</code>
37  * instead (when appropriate).
38  *
39  * <p>Note: This interface extends the <code>java.io.Serializable</code>
40  * marker interface. Implementations, which typically hold disconnected data,
41  * are encouraged to be actually serializable (as far as possible).
42  *
43  * @author Thomas Risberg
44  * @author Juergen Hoeller
45  * @since 1.2
46  * @see javax.sql.RowSet
47  * @see java.sql.ResultSet
48  * @see org.springframework.jdbc.InvalidResultSetAccessException
49  * @see org.springframework.jdbc.core.JdbcTemplate#queryForRowSet
50  */

51 public interface SqlRowSet extends Serializable JavaDoc {
52
53     /**
54      * Retrieves the meta data (number, types and properties for the columns)
55      * of this row set.
56      * @return a corresponding SqlRowSetMetaData instance
57      * @see java.sql.ResultSet#getMetaData()
58      */

59     SqlRowSetMetaData getMetaData();
60
61     /**
62      * Maps the given column name to its column index.
63      * @param columnName the name of the column
64      * @return the column index for the given column name
65      * @see java.sql.ResultSet#findColumn(String)
66      */

67     int findColumn(String JavaDoc columnName) throws InvalidResultSetAccessException;
68
69
70     // RowSet methods for extracting data values
71

72     /**
73      * Retrieves the value of the indicated column in the current row as
74      * an BigDecimal object.
75      * @param columnIndex the column index
76      * @return an BigDecimal object representing the column value
77      * @see java.sql.ResultSet#getBigDecimal(int)
78      */

79     BigDecimal JavaDoc getBigDecimal(int columnIndex) throws InvalidResultSetAccessException;
80
81     /**
82      * Retrieves the value of the indicated column in the current row as
83      * an BigDecimal object.
84      * @param columnName the column name
85      * @return an BigDecimal object representing the column value
86      * @see java.sql.ResultSet#getBigDecimal(java.lang.String)
87      */

88     BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName) throws InvalidResultSetAccessException;
89
90     /**
91      * Retrieves the value of the indicated column in the current row as
92      * a boolean.
93      * @param columnIndex the column index
94      * @return a boolean representing the column value
95      * @see java.sql.ResultSet#getBoolean(int)
96      */

97     boolean getBoolean(int columnIndex) throws InvalidResultSetAccessException;
98
99     /**
100      * Retrieves the value of the indicated column in the current row as
101      * a boolean.
102      * @param columnName the column name
103      * @return a boolean representing the column value
104      * @see java.sql.ResultSet#getBoolean(java.lang.String)
105      */

106     boolean getBoolean(String JavaDoc columnName) throws InvalidResultSetAccessException;
107
108     /**
109      * Retrieves the value of the indicated column in the current row as
110      * a byte.
111      * @param columnIndex the column index
112      * @return a byte representing the column value
113      * @see java.sql.ResultSet#getByte(int)
114      */

115     byte getByte(int columnIndex) throws InvalidResultSetAccessException;
116
117     /**
118      * Retrieves the value of the indicated column in the current row as
119      * a byte.
120      * @param columnName the column name
121      * @return a byte representing the column value
122      * @see java.sql.ResultSet#getByte(java.lang.String)
123      */

124     byte getByte(String JavaDoc columnName) throws InvalidResultSetAccessException;
125
126     /**
127      * Retrieves the value of the indicated column in the current row as
128      * a Date object.
129      * @param columnIndex the column index
130      * @param cal the Calendar to use in constructing the Date
131      * @return a Date object representing the column value
132      * @see java.sql.ResultSet#getDate(int, java.util.Calendar)
133      */

134     Date JavaDoc getDate(int columnIndex, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
135
136     /**
137      * Retrieves the value of the indicated column in the current row as
138      * a Date object.
139      * @param columnIndex the column index
140      * @return a Date object representing the column value
141      * @see java.sql.ResultSet#getDate(int)
142      */

143     Date JavaDoc getDate(int columnIndex) throws InvalidResultSetAccessException;
144
145     /**
146      * Retrieves the value of the indicated column in the current row as
147      * a Date object.
148      * @param columnName the column name
149      * @param cal the Calendar to use in constructing the Date
150      * @return a Date object representing the column value
151      * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)
152      */

153     Date JavaDoc getDate(String JavaDoc columnName, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
154
155     /**
156      * Retrieves the value of the indicated column in the current row as
157      * a Date object.
158      * @param columnName the column name
159      * @return a Date object representing the column value
160      * @see java.sql.ResultSet#getDate(java.lang.String)
161      */

162     Date JavaDoc getDate(String JavaDoc columnName) throws InvalidResultSetAccessException;
163
164     /**
165      * Retrieves the value of the indicated column in the current row as
166      * a Double object.
167      * @param columnIndex the column index
168      * @return a Double object representing the column value
169      * @see java.sql.ResultSet#getDouble(int)
170      */

171     double getDouble(int columnIndex) throws InvalidResultSetAccessException;
172
173     /**
174      * Retrieves the value of the indicated column in the current row as
175      * a Double object.
176      * @param columnName the column name
177      * @return a Double object representing the column value
178      * @see java.sql.ResultSet#getDouble(java.lang.String)
179      */

180     double getDouble(String JavaDoc columnName) throws InvalidResultSetAccessException;
181
182     /**
183      * Retrieves the value of the indicated column in the current row as
184      * a float.
185      * @param columnIndex the column index
186      * @return a float representing the column value
187      * @see java.sql.ResultSet#getFloat(int)
188      */

189     float getFloat(int columnIndex) throws InvalidResultSetAccessException;
190
191     /**
192      * Retrieves the value of the indicated column in the current row as
193      * a float.
194      * @param columnName the column name
195      * @return a float representing the column value
196      * @see java.sql.ResultSet#getFloat(java.lang.String)
197      */

198     float getFloat(String JavaDoc columnName) throws InvalidResultSetAccessException;
199
200     /**
201      * Retrieves the value of the indicated column in the current row as
202      * an int.
203      * @param columnIndex the column index
204      * @return an int representing the column value
205      * @see java.sql.ResultSet#getInt(int)
206      */

207     int getInt(int columnIndex) throws InvalidResultSetAccessException;
208
209     /**
210      * Retrieves the value of the indicated column in the current row as
211      * an int.
212      * @param columnName the column name
213      * @return an int representing the column value
214      * @see java.sql.ResultSet#getInt(java.lang.String)
215      */

216     int getInt(String JavaDoc columnName) throws InvalidResultSetAccessException;
217
218     /**
219      * Retrieves the value of the indicated column in the current row as
220      * a long.
221      * @param columnIndex the column index
222      * @return a long representing the column value
223      * @see java.sql.ResultSet#getLong(int)
224      */

225     long getLong(int columnIndex) throws InvalidResultSetAccessException;
226
227     /**
228      * Retrieves the value of the indicated column in the current row as
229      * a long.
230      * @param columnName the column name
231      * @return a long representing the column value
232      * @see java.sql.ResultSet#getLong(java.lang.String)
233      */

234     long getLong(String JavaDoc columnName) throws InvalidResultSetAccessException;
235
236     /**
237      * Retrieves the value of the indicated column in the current row as
238      * an Object.
239      * @param columnIndex the column index
240      * @param map a Map object containing the mapping from SQL types to Java types
241      * @return a Object representing the column value
242      * @see java.sql.ResultSet#getObject(int, java.util.Map)
243      */

244     Object JavaDoc getObject(int columnIndex, Map JavaDoc map) throws InvalidResultSetAccessException;
245
246     /**
247      * Retrieves the value of the indicated column in the current row as
248      * an Object.
249      * @param columnIndex the column index
250      * @return a Object representing the column value
251      * @see java.sql.ResultSet#getObject(int)
252      */

253     Object JavaDoc getObject(int columnIndex) throws InvalidResultSetAccessException;
254
255     /**
256      * Retrieves the value of the indicated column in the current row as
257      * an Object.
258      * @param columnName the column name
259      * @param map a Map object containing the mapping from SQL types to Java types
260      * @return a Object representing the column value
261      * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map)
262      */

263     Object JavaDoc getObject(String JavaDoc columnName, Map JavaDoc map) throws InvalidResultSetAccessException;
264
265     /**
266      * Retrieves the value of the indicated column in the current row as
267      * an Object.
268      * @param columnName the column name
269      * @return a Object representing the column value
270      * @see java.sql.ResultSet#getObject(java.lang.String)
271      */

272     Object JavaDoc getObject(String JavaDoc columnName) throws InvalidResultSetAccessException;
273
274     /**
275      * Retrieves the value of the indicated column in the current row as
276      * a short.
277      * @param columnIndex the column index
278      * @return a short representing the column value
279      * @see java.sql.ResultSet#getShort(int)
280      */

281     short getShort(int columnIndex) throws InvalidResultSetAccessException;
282
283     /**
284      * Retrieves the value of the indicated column in the current row as
285      * a short.
286      * @param columnName the column name
287      * @return a short representing the column value
288      * @see java.sql.ResultSet#getShort(java.lang.String)
289      */

290     short getShort(String JavaDoc columnName) throws InvalidResultSetAccessException;
291
292     /**
293      * Retrieves the value of the indicated column in the current row as
294      * a String.
295      * @param columnIndex the column index
296      * @return a String representing the column value
297      * @see java.sql.ResultSet#getString(int)
298      */

299     String JavaDoc getString(int columnIndex) throws InvalidResultSetAccessException;
300
301     /**
302      * Retrieves the value of the indicated column in the current row as
303      * a String.
304      * @param columnName the column name
305      * @return a String representing the column value
306      * @see java.sql.ResultSet#getString(java.lang.String)
307      */

308     String JavaDoc getString(String JavaDoc columnName) throws InvalidResultSetAccessException;
309
310     /**
311      * Retrieves the value of the indicated column in the current row as
312      * a Time object.
313      * @param columnIndex the column index
314      * @param cal the Calendar to use in constructing the Date
315      * @return a Time object representing the column value
316      * @see java.sql.ResultSet#getTime(int, java.util.Calendar)
317      */

318     Time JavaDoc getTime(int columnIndex, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
319
320     /**
321      * Retrieves the value of the indicated column in the current row as
322      * a Time object.
323      * @param columnIndex the column index
324      * @return a Time object representing the column value
325      * @see java.sql.ResultSet#getTime(int)
326      */

327     Time JavaDoc getTime(int columnIndex) throws InvalidResultSetAccessException;
328
329     /**
330      * Retrieves the value of the indicated column in the current row as
331      * a Time object.
332      * @param columnName the column name
333      * @param cal the Calendar to use in constructing the Date
334      * @return a Time object representing the column value
335      * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)
336      */

337     Time JavaDoc getTime(String JavaDoc columnName, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
338
339     /**
340      * Retrieves the value of the indicated column in the current row as
341      * a Time object.
342      * @param columnName the column name
343      * @return a Time object representing the column value
344      * @see java.sql.ResultSet#getTime(java.lang.String)
345      */

346     Time JavaDoc getTime(String JavaDoc columnName) throws InvalidResultSetAccessException;
347
348     /**
349      * Retrieves the value of the indicated column in the current row as
350      * a Timestamp object.
351      * @param columnIndex the column index
352      * @param cal the Calendar to use in constructing the Date
353      * @return a Timestamp object representing the column value
354      * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)
355      */

356     Timestamp JavaDoc getTimestamp(int columnIndex, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
357
358     /**
359      * Retrieves the value of the indicated column in the current row as
360      * a Timestamp object.
361      * @param columnIndex the column index
362      * @return a Timestamp object representing the column value
363      * @see java.sql.ResultSet#getTimestamp(int)
364      */

365     Timestamp JavaDoc getTimestamp(int columnIndex) throws InvalidResultSetAccessException;
366
367     /**
368      * Retrieves the value of the indicated column in the current row as
369      * a Timestamp object.
370      * @param columnName the column name
371      * @param cal the Calendar to use in constructing the Date
372      * @return a Timestamp object representing the column value
373      * @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)
374      */

375     Timestamp JavaDoc getTimestamp(String JavaDoc columnName, Calendar JavaDoc cal) throws InvalidResultSetAccessException;
376
377     /**
378      * Retrieves the value of the indicated column in the current row as
379      * a Timestamp object.
380      * @param columnName the column name
381      * @return a Timestamp object representing the column value
382      * @see java.sql.ResultSet#getTimestamp(java.lang.String)
383      */

384     Timestamp JavaDoc getTimestamp(String JavaDoc columnName) throws InvalidResultSetAccessException;
385
386
387     // RowSet navigation methods
388

389     /**
390      * Moves the cursor to the given row number in the RowSet, just after the last row.
391      * @param row the number of the row where the cursor should move
392      * @return true if the cursor is on the RowSet, false otherwise
393      * @see java.sql.ResultSet#absolute(int)
394      */

395     boolean absolute(int row) throws InvalidResultSetAccessException;
396
397     /**
398      * Moves the cursor to the end of this RowSet.
399      * @see java.sql.ResultSet#afterLast()
400      */

401     void afterLast() throws InvalidResultSetAccessException;
402
403     /**
404      * Moves the cursor to the front of this RowSet, just before the first row.
405      * @see java.sql.ResultSet#beforeFirst()
406      */

407     void beforeFirst() throws InvalidResultSetAccessException;
408
409     /**
410      * Moves the cursor to the first row of this RowSet.
411      * @return true if the cursor is on a valid row, false otherwise
412      * @see java.sql.ResultSet#first()
413      */

414     boolean first() throws InvalidResultSetAccessException;
415
416     /**
417      * Retrieves the current row number.
418      * @return the current row number
419      * @see java.sql.ResultSet#getRow()
420      */

421     int getRow() throws InvalidResultSetAccessException;
422
423     /**
424      * Retrieves whether the cursor is after the last row of this RowSet.
425      * @return true if the cursor is after the last row, false otherwise
426      * @see java.sql.ResultSet#isAfterLast()
427      */

428     boolean isAfterLast() throws InvalidResultSetAccessException;
429
430     /**
431      * Retrieves whether the cursor is after the first row of this RowSet.
432      * @return true if the cursor is after the first row, false otherwise
433      * @see java.sql.ResultSet#isBeforeFirst()
434      */

435     boolean isBeforeFirst() throws InvalidResultSetAccessException;
436
437     /**
438      * Retrieves whether the cursor is on the first row of this RowSet.
439      * @return true if the cursor is after the first row, false otherwise
440      * @see java.sql.ResultSet#isFirst()
441      */

442     boolean isFirst() throws InvalidResultSetAccessException;
443
444     /**
445      * Retrieves whether the cursor is on the last row of this RowSet.
446      * @return true if the cursor is after the last row, false otherwise
447      * @see java.sql.ResultSet#isLast()
448      */

449     boolean isLast() throws InvalidResultSetAccessException;
450
451     /**
452      * Moves the cursor to the last row of this RowSet.
453      * @return true if the cursor is on a valid row, false otherwise
454      * @see java.sql.ResultSet#last()
455      */

456     boolean last() throws InvalidResultSetAccessException;
457
458     /**
459      * Moves the cursor to the next row.
460      * @return true if the new row is valid, false if there are no more rows
461      * @see java.sql.ResultSet#next()
462      */

463     boolean next() throws InvalidResultSetAccessException;
464
465     /**
466      * Moves the cursor to the previous row.
467      * @return true if the new row is valid, false if it is off the RowSet
468      * @see java.sql.ResultSet#previous()
469      */

470     boolean previous() throws InvalidResultSetAccessException;
471
472     /**
473      * Moves the cursor a relative number f rows, either positive or negative.
474      * @return true if the cursor is on a row, false otherwise
475      * @see java.sql.ResultSet#relative(int)
476      */

477     boolean relative(int rows) throws InvalidResultSetAccessException;
478
479     /**
480      * Reports whether the last column read had a value of SQL <code>NULL</code>.
481      * Note that you must first call one of the getter methods and then call
482      * the <code>wasNull</code> method.
483      * @return true if the most recent coumn retrieved was SQL <code>NULL</code>,
484      * false otherwise
485      * @see java.sql.ResultSet#wasNull()
486      */

487     boolean wasNull() throws InvalidResultSetAccessException;
488
489 }
490
Popular Tags