001: /*
002: * Copyright 2004 Clinton Begin
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package com.ibatis.sqlmap.client.extensions;
017:
018: import java.math.BigDecimal;
019: import java.net.URL;
020: import java.sql.*;
021: import java.util.Calendar;
022: import java.util.Map;
023:
024: /**
025: * Allows values to be retrieved from the underlying result set.
026: * TypeHandlerCallback implementations use this interface to
027: * get values that they can subsequently manipulate before
028: * having them returned. Each of these methods has a corresponding
029: * method on the ResultSet (or CallableStatement) class, the only
030: * difference being that there is no need to specify the column name
031: * or index with these methods.
032: * <p/>
033: * <b>NOTE:</b> There is no need to implement this. The implementation
034: * will be passed into the TypeHandlerCallback automatically.
035: */
036: public interface ResultGetter {
037:
038: /**
039: * Gets an array from the underlying result set
040: * @return - the array
041: * @throws SQLException - if the underlying result set throws an exception
042: */
043: public Array getArray() throws SQLException;
044:
045: /**
046: * Gets a BigDecimal from the underlying result set
047: * @return - the BigDecimal
048: * @throws SQLException - if the underlying result set throws an exception
049: */
050: public BigDecimal getBigDecimal() throws SQLException;
051:
052: /**
053: * Gets a Blob from the underlying result set
054: * @return - the Blob
055: * @throws SQLException - if the underlying result set throws an exception
056: */
057: public Blob getBlob() throws SQLException;
058:
059: /**
060: * Gets a boolean from the underlying result set
061: * @return - the boolean
062: * @throws SQLException - if the underlying result set throws an exception
063: */
064: public boolean getBoolean() throws SQLException;
065:
066: /**
067: * Gets a byte from the underlying result set
068: * @return - the byte
069: * @throws SQLException - if the underlying result set throws an exception
070: */
071: public byte getByte() throws SQLException;
072:
073: /**
074: * Gets a byte[] from the underlying result set
075: * @return - the byte[]
076: * @throws SQLException - if the underlying result set throws an exception
077: */
078: public byte[] getBytes() throws SQLException;
079:
080: /**
081: * Gets a Clob from the underlying result set
082: * @return - the Clob
083: * @throws SQLException - if the underlying result set throws an exception
084: */
085: public Clob getClob() throws SQLException;
086:
087: /**
088: * Gets a Date from the underlying result set
089: * @return - the Date
090: * @throws SQLException - if the underlying result set throws an exception
091: */
092: public Date getDate() throws SQLException;
093:
094: /**
095: * Gets a Date from the underlying result set using a calendar
096: * @param cal - the Calendar
097: * @return - the Date
098: * @throws SQLException - if the underlying result set throws an exception
099: */
100: public Date getDate(Calendar cal) throws SQLException;
101:
102: /**
103: * Gets a double from the underlying result set
104: * @return - the double
105: * @throws SQLException - if the underlying result set throws an exception
106: */
107: public double getDouble() throws SQLException;
108:
109: /**
110: * Gets a float from the underlying result set
111: * @return - the float
112: * @throws SQLException - if the underlying result set throws an exception
113: */
114: public float getFloat() throws SQLException;
115:
116: /**
117: * Gets an int from the underlying result set
118: * @return - the int
119: * @throws SQLException - if the underlying result set throws an exception
120: */
121: public int getInt() throws SQLException;
122:
123: /**
124: * Gets a long from the underlying result set
125: * @return - the long
126: * @throws SQLException - if the underlying result set throws an exception
127: */
128: public long getLong() throws SQLException;
129:
130: /**
131: * Gets an Object from the underlying result set
132: * @return - the Object
133: * @throws SQLException - if the underlying result set throws an exception
134: */
135: public Object getObject() throws SQLException;
136:
137: /**
138: * Gets an Object from the underlying result set using a Map
139: * @param map - the Map
140: * @return - the Object
141: * @throws SQLException - if the underlying result set throws an exception
142: */
143: public Object getObject(Map map) throws SQLException;
144:
145: /**
146: * Gets a Ref from the underlying result set
147: * @return - the Ref
148: * @throws SQLException - if the underlying result set throws an exception
149: */
150: public Ref getRef() throws SQLException;
151:
152: /**
153: * Gets a short from the underlying result set
154: * @return - the short
155: * @throws SQLException - if the underlying result set throws an exception
156: */
157: public short getShort() throws SQLException;
158:
159: /**
160: * Gets a String from the underlying result set
161: * @return - the String
162: * @throws SQLException - if the underlying result set throws an exception
163: */
164: public String getString() throws SQLException;
165:
166: /**
167: * Gets a Time from the underlying result set
168: * @return - the Time
169: * @throws SQLException - if the underlying result set throws an exception
170: */
171: public Time getTime() throws SQLException;
172:
173: /**
174: * Gets a Time from the underlying result set using a Calendar
175: * @param cal - the Calendar
176: * @return - the Time
177: * @throws SQLException - if the underlying result set throws an exception
178: */
179: public Time getTime(Calendar cal) throws SQLException;
180:
181: /**
182: * Gets a Timestamp from the underlying result set
183: * @return - the Timestamp
184: * @throws SQLException - if the underlying result set throws an exception
185: */
186: public Timestamp getTimestamp() throws SQLException;
187:
188: /**
189: * Gets a Timestamp from the underlying result set
190: * @param cal - the Calendar
191: * @return - the Timestamp
192: * @throws SQLException - if the underlying result set throws an exception
193: */
194: public Timestamp getTimestamp(Calendar cal) throws SQLException;
195:
196: /**
197: * Gets a URL from the underlying result set
198: * @return - the URL
199: * @throws SQLException - if the underlying result set throws an exception
200: */
201: public URL getURL() throws SQLException;
202:
203: /**
204: * Tells if the field was null
205: * @return - true if it was null
206: * @throws SQLException - if the underlying result set throws an exception
207: */
208: public boolean wasNull() throws SQLException;
209:
210: /**
211: * Returns the underlying ResultSet...be careful!
212: * @return a ResultSet instance.
213: */
214: public ResultSet getResultSet();
215:
216: /**
217: * Returns the name of the column being got in the underlying ResultSet.
218: * May be <code>null</code> in which case the <code>getColumnIndex</code>
219: * method should be used.
220: *
221: * @return the column name (may be null)
222: */
223: public String getColumnName();
224:
225: /**
226: * Returns the index of the column being got in the underlying ResultSet.
227: * Only use this method if the value returned from <code>getColumnName</code>
228: * is null.
229: *
230: * @return the index of the column (if zero then use the column name)
231: */
232: public int getColumnIndex();
233: }
|