KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > RowData


1 /*
2    Copyright (C) 2002 MySQL AB
3
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8
9       This program is distributed in the hope that it will be useful,
10       but WITHOUT ANY WARRANTY; without even the implied warranty of
11       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12       GNU General Public License for more details.
13
14       You should have received a copy of the GNU General Public License
15       along with this program; if not, write to the Free Software
16       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18  */

19 package com.mysql.jdbc;
20
21 import java.sql.SQLException JavaDoc;
22
23
24 /**
25  * This interface abstracts away how row data is accessed by
26  * the result set. It is meant to allow a static implementation
27  * (Current version), and a streaming one.
28  *
29  * @author dgan
30  */

31 public interface RowData {
32     /**
33      * What's returned for the size of a result set
34      * when its size can not be determined.
35      */

36     public static final int RESULT_SET_SIZE_UNKNOWN = -1;
37
38     /**
39      * Returns true if we got the last element.
40      *
41      * @return true if after last row
42      * @throws SQLException if a database error occurs
43      */

44     boolean isAfterLast() throws SQLException JavaDoc;
45
46     /**
47      * Only works on non dynamic result sets.
48      *
49      * @param index row number to get at
50      * @return row data at index
51      * @throws SQLException if a database error occurs
52      */

53     byte[][] getAt(int index) throws SQLException JavaDoc;
54
55     /**
56      * Returns if iteration has not occured yet.
57      *
58      * @return true if before first row
59      * @throws SQLException if a database error occurs
60      */

61     boolean isBeforeFirst() throws SQLException JavaDoc;
62
63     /**
64      * Moves the current position in the result set to
65      * the given row number.
66      *
67      * @param rowNumber row to move to
68      * @throws SQLException if a database error occurs
69      */

70     void setCurrentRow(int rowNumber) throws SQLException JavaDoc;
71
72     /**
73      * Returns the current position in the result set as
74      * a row number.
75      *
76      * @return the current row number
77      * @throws SQLException if a database error occurs
78      */

79     int getCurrentRowNumber() throws SQLException JavaDoc;
80
81     /**
82      * Returns true if the result set is dynamic.
83      *
84      * This means that move back and move forward won't work
85      * because we do not hold on to the records.
86      *
87      * @return true if this result set is streaming from the server
88      * @throws SQLException if a database error occurs
89      */

90     boolean isDynamic() throws SQLException JavaDoc;
91
92     /**
93      * Has no records.
94      *
95      * @return true if no records
96      * @throws SQLException if a database error occurs
97      */

98     boolean isEmpty() throws SQLException JavaDoc;
99
100     /**
101      * Are we on the first row of the result set?
102      *
103      * @return true if on first row
104      * @throws SQLException if a database error occurs
105      */

106     boolean isFirst() throws SQLException JavaDoc;
107
108     /**
109      * Are we on the last row of the result set?
110      *
111      * @return true if on last row
112      * @throws SQLException if a database error occurs
113      */

114     boolean isLast() throws SQLException JavaDoc;
115
116     /**
117      * Adds a row to this row data.
118      *
119      * @param row the row to add
120      * @throws SQLException if a database error occurs
121      */

122     void addRow(byte[][] row) throws SQLException JavaDoc;
123
124     /**
125      * Moves to after last.
126      *
127      * @throws SQLException if a database error occurs
128      */

129     void afterLast() throws SQLException JavaDoc;
130
131     /**
132      * Moves to before first.
133      *
134      * @throws SQLException if a database error occurs
135      */

136     void beforeFirst() throws SQLException JavaDoc;
137
138     /**
139      * Moves to before last so next el is the last el.
140      *
141      * @throws SQLException if a database error occurs
142      */

143     void beforeLast() throws SQLException JavaDoc;
144
145     /**
146      * We're done.
147      *
148      * @throws SQLException if a database error occurs
149      */

150     void close() throws SQLException JavaDoc;
151
152     /**
153      * Returns true if another row exsists.
154      *
155      * @return true if more rows
156      * @throws SQLException if a database error occurs
157      */

158     boolean hasNext() throws SQLException JavaDoc;
159
160     /**
161      * Moves the current position relative 'rows' from
162      * the current position.
163      *
164      * @param rows the relative number of rows to move
165      * @throws SQLException if a database error occurs
166      */

167     void moveRowRelative(int rows) throws SQLException JavaDoc;
168
169     /**
170      * Returns the next row.
171      *
172      * @return the next row value
173      * @throws SQLException if a database error occurs
174      */

175     byte[][] next() throws SQLException JavaDoc;
176
177     /**
178      * Removes the row at the given index.
179      *
180      * @param index the row to move to
181      * @throws SQLException if a database error occurs
182      */

183     void removeRow(int index) throws SQLException JavaDoc;
184
185     /**
186      * Only works on non dynamic result sets.
187      *
188      * @return the size of this row data
189      * @throws SQLException if a database error occurs
190      */

191     int size() throws SQLException JavaDoc;
192     
193     /**
194      * Set the result set that 'owns' this RowData
195      *
196      * @param rs the result set that 'owns' this RowData
197      */

198     void setOwner(ResultSet rs);
199     
200     /**
201      * Returns the result set that 'owns' this RowData
202      *
203      * @return the result set that 'owns' this RowData
204      */

205     ResultSet getOwner();
206
207 }
208
Popular Tags