View Javadoc
1   /*
2    * Copyright 2004-2025 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    *    https://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  package com.ibatis.sqlmap.client.extensions;
17  
18  import java.math.BigDecimal;
19  import java.net.URL;
20  import java.sql.Array;
21  import java.sql.Blob;
22  import java.sql.Clob;
23  import java.sql.Date;
24  import java.sql.Ref;
25  import java.sql.ResultSet;
26  import java.sql.SQLException;
27  import java.sql.Time;
28  import java.sql.Timestamp;
29  import java.util.Calendar;
30  import java.util.Map;
31  
32  /**
33   * Allows values to be retrieved from the underlying result set. TypeHandlerCallback implementations use this interface
34   * to get values that they can subsequently manipulate before having them returned. Each of these methods has a
35   * corresponding method on the ResultSet (or CallableStatement) class, the only difference being that there is no need
36   * to specify the column name or index with these methods.
37   * <p>
38   * <b>NOTE:</b> There is no need to implement this. The implementation will be passed into the TypeHandlerCallback
39   * automatically.
40   */
41  public interface ResultGetter {
42  
43    /**
44     * Gets an array from the underlying result set.
45     *
46     * @return - the array
47     *
48     * @throws SQLException
49     *           - if the underlying result set throws an exception
50     */
51    Array getArray() throws SQLException;
52  
53    /**
54     * Gets a BigDecimal from the underlying result set.
55     *
56     * @return - the BigDecimal
57     *
58     * @throws SQLException
59     *           - if the underlying result set throws an exception
60     */
61    BigDecimal getBigDecimal() throws SQLException;
62  
63    /**
64     * Gets a Blob from the underlying result set.
65     *
66     * @return - the Blob
67     *
68     * @throws SQLException
69     *           - if the underlying result set throws an exception
70     */
71    Blob getBlob() throws SQLException;
72  
73    /**
74     * Gets a boolean from the underlying result set.
75     *
76     * @return - the boolean
77     *
78     * @throws SQLException
79     *           - if the underlying result set throws an exception
80     */
81    boolean getBoolean() throws SQLException;
82  
83    /**
84     * Gets a byte from the underlying result set.
85     *
86     * @return - the byte
87     *
88     * @throws SQLException
89     *           - if the underlying result set throws an exception
90     */
91    byte getByte() throws SQLException;
92  
93    /**
94     * Gets a byte[] from the underlying result set.
95     *
96     * @return - the byte[]
97     *
98     * @throws SQLException
99     *           - if the underlying result set throws an exception
100    */
101   byte[] getBytes() throws SQLException;
102 
103   /**
104    * Gets a Clob from the underlying result set.
105    *
106    * @return - the Clob
107    *
108    * @throws SQLException
109    *           - if the underlying result set throws an exception
110    */
111   Clob getClob() throws SQLException;
112 
113   /**
114    * Gets a Date from the underlying result set.
115    *
116    * @return - the Date
117    *
118    * @throws SQLException
119    *           - if the underlying result set throws an exception
120    */
121   Date getDate() throws SQLException;
122 
123   /**
124    * Gets a Date from the underlying result set using a calendar.
125    *
126    * @param cal
127    *          - the Calendar
128    *
129    * @return - the Date
130    *
131    * @throws SQLException
132    *           - if the underlying result set throws an exception
133    */
134   Date getDate(Calendar cal) throws SQLException;
135 
136   /**
137    * Gets a double from the underlying result set.
138    *
139    * @return - the double
140    *
141    * @throws SQLException
142    *           - if the underlying result set throws an exception
143    */
144   double getDouble() throws SQLException;
145 
146   /**
147    * Gets a float from the underlying result set.
148    *
149    * @return - the float
150    *
151    * @throws SQLException
152    *           - if the underlying result set throws an exception
153    */
154   float getFloat() throws SQLException;
155 
156   /**
157    * Gets an int from the underlying result set.
158    *
159    * @return - the int
160    *
161    * @throws SQLException
162    *           - if the underlying result set throws an exception
163    */
164   int getInt() throws SQLException;
165 
166   /**
167    * Gets a long from the underlying result set.
168    *
169    * @return - the long
170    *
171    * @throws SQLException
172    *           - if the underlying result set throws an exception
173    */
174   long getLong() throws SQLException;
175 
176   /**
177    * Gets an Object from the underlying result set.
178    *
179    * @return - the Object
180    *
181    * @throws SQLException
182    *           - if the underlying result set throws an exception
183    */
184   Object getObject() throws SQLException;
185 
186   /**
187    * Gets an Object from the underlying result set using a Map.
188    *
189    * @param map
190    *          - the Map
191    *
192    * @return - the Object
193    *
194    * @throws SQLException
195    *           - if the underlying result set throws an exception
196    */
197   Object getObject(Map map) throws SQLException;
198 
199   /**
200    * Gets a Ref from the underlying result set.
201    *
202    * @return - the Ref
203    *
204    * @throws SQLException
205    *           - if the underlying result set throws an exception
206    */
207   Ref getRef() throws SQLException;
208 
209   /**
210    * Gets a short from the underlying result set.
211    *
212    * @return - the short
213    *
214    * @throws SQLException
215    *           - if the underlying result set throws an exception
216    */
217   short getShort() throws SQLException;
218 
219   /**
220    * Gets a String from the underlying result set.
221    *
222    * @return - the String
223    *
224    * @throws SQLException
225    *           - if the underlying result set throws an exception
226    */
227   String getString() throws SQLException;
228 
229   /**
230    * Gets a Time from the underlying result set.
231    *
232    * @return - the Time
233    *
234    * @throws SQLException
235    *           - if the underlying result set throws an exception
236    */
237   Time getTime() throws SQLException;
238 
239   /**
240    * Gets a Time from the underlying result set using a Calendar.
241    *
242    * @param cal
243    *          - the Calendar
244    *
245    * @return - the Time
246    *
247    * @throws SQLException
248    *           - if the underlying result set throws an exception
249    */
250   Time getTime(Calendar cal) throws SQLException;
251 
252   /**
253    * Gets a Timestamp from the underlying result set.
254    *
255    * @return - the Timestamp
256    *
257    * @throws SQLException
258    *           - if the underlying result set throws an exception
259    */
260   Timestamp getTimestamp() throws SQLException;
261 
262   /**
263    * Gets a Timestamp from the underlying result set.
264    *
265    * @param cal
266    *          - the Calendar
267    *
268    * @return - the Timestamp
269    *
270    * @throws SQLException
271    *           - if the underlying result set throws an exception
272    */
273   Timestamp getTimestamp(Calendar cal) throws SQLException;
274 
275   /**
276    * Gets a URL from the underlying result set.
277    *
278    * @return - the URL
279    *
280    * @throws SQLException
281    *           - if the underlying result set throws an exception
282    */
283   URL getURL() throws SQLException;
284 
285   /**
286    * Tells if the field was null.
287    *
288    * @return - true if it was null
289    *
290    * @throws SQLException
291    *           - if the underlying result set throws an exception
292    */
293   boolean wasNull() throws SQLException;
294 
295   /**
296    * Returns the underlying ResultSet...be careful!
297    *
298    * @return a ResultSet instance.
299    */
300   ResultSet getResultSet();
301 
302   /**
303    * Returns the name of the column being got in the underlying ResultSet. May be <code>null</code> in which case the
304    * <code>getColumnIndex</code> method should be used.
305    *
306    * @return the column name (may be null)
307    */
308   String getColumnName();
309 
310   /**
311    * Returns the index of the column being got in the underlying ResultSet. Only use this method if the value returned
312    * from <code>getColumnName</code> is null.
313    *
314    * @return the index of the column (if zero then use the column name)
315    */
316   int getColumnIndex();
317 }