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.io.InputStream;
019: import java.io.Reader;
020: import java.math.BigDecimal;
021: import java.net.URL;
022: import java.sql.*;
023: import java.util.Calendar;
024:
025: /**
026: * Allows parameters to be set on the underlying prepared statement.
027: * TypeHandlerCallback implementations use this interface to
028: * process values before they are set on the prepared statement.
029: * Each of these methods has a corresponding method on the
030: * PreparedStatement class, the only difference being
031: * that there is no need to specify the parameter index with these
032: * methods.
033: * <p/>
034: * <b>NOTE:</b> There is no need to implement this. The implementation
035: * will be passed into the TypeHandlerCallback automatically.
036: */
037: public interface ParameterSetter {
038:
039: /**
040: * Set an array on the underlying prepared statement
041: * @param x - the array to set
042: * @throws SQLException - thrown if the underlying prepared statement throws it
043: */
044: public void setArray(Array x) throws SQLException;
045:
046: /**
047: * Set an InputStream on the underlying prepared statement
048: * @param x - the InputStream
049: * @param length - the length of the InputStream
050: * @throws SQLException - thrown if the underlying prepared statement throws it
051: */
052: public void setAsciiStream(InputStream x, int length)
053: throws SQLException;
054:
055: /**
056: * Set an on the underlying prepared statement
057: * @param x
058: * @throws SQLException - thrown if the underlying prepared statement throws it
059: */
060: public void setBigDecimal(BigDecimal x) throws SQLException;
061:
062: /**
063: * Set an InputStream on the underlying prepared statement
064: * @param x - the InputStream
065: * @param length - the length of the InputStream
066: * @throws SQLException - thrown if the underlying prepared statement throws it
067: */
068: public void setBinaryStream(InputStream x, int length)
069: throws SQLException;
070:
071: /**
072: * Set a blob on the underlying prepared statement
073: * @param x - the blob
074: * @throws SQLException - thrown if the underlying prepared statement throws it
075: */
076: public void setBlob(Blob x) throws SQLException;
077:
078: /**
079: * Set a boolean on the underlying prepared statement
080: * @param x - the boolean
081: * @throws SQLException - thrown if the underlying prepared statement throws it
082: */
083: public void setBoolean(boolean x) throws SQLException;
084:
085: /**
086: * Set a byte on the underlying prepared statement
087: * @param x - the byte
088: * @throws SQLException - thrown if the underlying prepared statement throws it
089: */
090: public void setByte(byte x) throws SQLException;
091:
092: /**
093: * Set a byte array on the underlying prepared statement
094: * @param x - the byte[]
095: * @throws SQLException - thrown if the underlying prepared statement throws it
096: */
097: public void setBytes(byte x[]) throws SQLException;
098:
099: /**
100: * Set a character stream on the underlying prepared statement
101: * @param reader - the reader
102: * @param length - the length of the reader
103: * @throws SQLException - thrown if the underlying prepared statement throws it
104: */
105: public void setCharacterStream(Reader reader, int length)
106: throws SQLException;
107:
108: /**
109: * Set a clob on the underlying prepared statement
110: * @param x - the clob
111: * @throws SQLException - thrown if the underlying prepared statement throws it
112: */
113: public void setClob(Clob x) throws SQLException;
114:
115: /**
116: * Set a date on the underlying prepared statement
117: * @param x - the date
118: * @throws SQLException - thrown if the underlying prepared statement throws it
119: */
120: public void setDate(Date x) throws SQLException;
121:
122: /**
123: * Set a date with a calendar on the underlying prepared statement
124: * @param x - the date
125: * @param cal - the calendar
126: * @throws SQLException - thrown if the underlying prepared statement throws it
127: */
128: public void setDate(Date x, Calendar cal) throws SQLException;
129:
130: /**
131: * Set a double on the underlying prepared statement
132: * @param x - the double
133: * @throws SQLException - thrown if the underlying prepared statement throws it
134: */
135: public void setDouble(double x) throws SQLException;
136:
137: /**
138: * Set a float on the underlying prepared statement
139: * @param x the float
140: * @throws SQLException - thrown if the underlying prepared statement throws it
141: */
142: public void setFloat(float x) throws SQLException;
143:
144: /**
145: * Set an integer on the underlying prepared statement
146: * @param x - the int
147: * @throws SQLException - thrown if the underlying prepared statement throws it
148: */
149: public void setInt(int x) throws SQLException;
150:
151: /**
152: * Set a long on the underlying prepared statement
153: * @param x - the long
154: * @throws SQLException - thrown if the underlying prepared statement throws it
155: */
156: public void setLong(long x) throws SQLException;
157:
158: /**
159: * Set a null on the underlying prepared statement
160: * @param sqlType - the type for the null value
161: * @throws SQLException - thrown if the underlying prepared statement throws it
162: */
163: public void setNull(int sqlType) throws SQLException;
164:
165: /**
166: * Set a null on the underlying prepared statement
167: * @param sqlType - the type for the null value
168: * @param typeName - the name of the type
169: * @throws SQLException - thrown if the underlying prepared statement throws it
170: */
171: public void setNull(int sqlType, String typeName)
172: throws SQLException;
173:
174: /**
175: * Set an object on the underlying prepared statement
176: * @param x - the object to set
177: * @throws SQLException - thrown if the underlying prepared statement throws it
178: */
179: public void setObject(Object x) throws SQLException;
180:
181: /**
182: * Set an object on the underlying prepared statement
183: * @param x - the object to set
184: * @param targetSqlType - the sql type of the object
185: * @throws SQLException - thrown if the underlying prepared statement throws it
186: */
187: public void setObject(Object x, int targetSqlType)
188: throws SQLException;
189:
190: /**
191: * Set an object on the underlying prepared statement
192: * @param x - the object to set
193: * @param targetSqlType - the sql type of the object
194: * @param scale - the scale of the object
195: * @throws SQLException - thrown if the underlying prepared statement throws it
196: */
197: public void setObject(Object x, int targetSqlType, int scale)
198: throws SQLException;
199:
200: /**
201: * Set a reference on the underlying prepared statement
202: * @param x - the reference to set
203: * @throws SQLException - thrown if the underlying prepared statement throws it
204: */
205: public void setRef(Ref x) throws SQLException;
206:
207: /**
208: * Set a short on the underlying prepared statement
209: * @param x - the short to set
210: * @throws SQLException - thrown if the underlying prepared statement throws it
211: */
212: public void setShort(short x) throws SQLException;
213:
214: /**
215: * Set a string on the underlying prepared statement
216: * @param x - the string to set
217: * @throws SQLException - thrown if the underlying prepared statement throws it
218: */
219: public void setString(String x) throws SQLException;
220:
221: /**
222: * Set a time on the underlying prepared statement
223: * @param x - the time to set
224: * @throws SQLException - thrown if the underlying prepared statement throws it
225: */
226: public void setTime(Time x) throws SQLException;
227:
228: /**
229: * Set a time with a calendar on the underlying prepared statement
230: * @param x - the time to set
231: * @param cal - the calendar to use
232: * @throws SQLException - thrown if the underlying prepared statement throws it
233: */
234: public void setTime(Time x, Calendar cal) throws SQLException;
235:
236: /**
237: * Set a timestamp on the underlying prepared statement
238: * @param x - the timestamp to set
239: * @throws SQLException - thrown if the underlying prepared statement throws it
240: */
241: public void setTimestamp(Timestamp x) throws SQLException;
242:
243: /**
244: * Set a timestamp on the underlying prepared statement
245: * @param x - the timestamp to set
246: * @param cal - the calendar to use
247: * @throws SQLException - thrown if the underlying prepared statement throws it
248: */
249: public void setTimestamp(Timestamp x, Calendar cal)
250: throws SQLException;
251:
252: /**
253: * Set a URL on the underlying prepared statement
254: * @param x - the url to set
255: * @throws SQLException - thrown if the underlying prepared statement throws it
256: */
257: public void setURL(URL x) throws SQLException;
258:
259: /**
260: * Returns the underlying prepared statement...be careful!
261: */
262: public PreparedStatement getPreparedStatement();
263:
264: /**
265: * Returns the index of the parameter being set.
266: *
267: * @return the parameter index used to set the value in the underlying
268: * PreparedStatement
269: */
270: public int getParameterIndex();
271: }
|