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