KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > type > TypeHandler


1 /*
2  * Copyright 2004 Clinton Begin
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  * http://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.engine.type;
17
18 import java.sql.CallableStatement JavaDoc;
19 import java.sql.PreparedStatement JavaDoc;
20 import java.sql.ResultSet JavaDoc;
21 import java.sql.SQLException JavaDoc;
22
23 /**
24  * Interface for getting data into, and out of a mapped statement
25  */

26 public interface TypeHandler {
27
28   /**
29    * Sets a parameter on a prepared statement
30    *
31    * @param ps - the prepared statement
32    * @param i - the parameter index
33    * @param parameter - the parameter value
34    * @param jdbcType - the JDBC type of the parameter
35    *
36    * @throws SQLException if setting the parameter fails
37    */

38   public void setParameter(PreparedStatement JavaDoc ps, int i, Object JavaDoc parameter, String JavaDoc jdbcType)
39       throws SQLException JavaDoc;
40
41   /**
42    * Gets a column from a result set
43    *
44    * @param rs - the result set
45    * @param columnName - the column name to get
46    *
47    * @return - the column value
48    *
49    * @throws SQLException if getting the value fails
50    */

51   public Object JavaDoc getResult(ResultSet JavaDoc rs, String JavaDoc columnName)
52       throws SQLException JavaDoc;
53
54   /**
55    * Gets a column from a result set
56    *
57    * @param rs - the result set
58    * @param columnIndex - the column to get (by index)
59    *
60    * @return - the column value
61    *
62    * @throws SQLException if getting the value fails
63    */

64   public Object JavaDoc getResult(ResultSet JavaDoc rs, int columnIndex)
65       throws SQLException JavaDoc;
66
67   /**
68    * Gets a column from a callable statement
69    *
70    * @param cs - the statement
71    * @param columnIndex - the column to get (by index)
72    *
73    * @return - the column value
74    *
75    * @throws SQLException if getting the value fails
76    */

77   public Object JavaDoc getResult(CallableStatement JavaDoc cs, int columnIndex)
78       throws SQLException JavaDoc;
79
80   /**
81    * Converts the String to the type that this handler deals with
82    *
83    * @param s - the String value
84    *
85    * @return - the converted value
86    */

87   public Object JavaDoc valueOf(String JavaDoc s);
88
89   /**
90    * Compares two values (that this handler deals with) for equality
91    *
92    * @param object - one of the objects
93    * @param string - the other object as a String
94    *
95    * @return - true if they are equal
96    */

97   public boolean equals(Object JavaDoc object, String JavaDoc string);
98
99 }
100
Popular Tags