01: /*
02: * Copyright 2004 Clinton Begin
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
19: import java.sql.PreparedStatement;
20: import java.sql.ResultSet;
21: import java.sql.SQLException;
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 ps, int i,
39: Object parameter, String jdbcType) throws SQLException;
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 getResult(ResultSet rs, String columnName)
52: throws SQLException;
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 getResult(ResultSet rs, int columnIndex)
65: throws SQLException;
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 getResult(CallableStatement cs, int columnIndex)
78: throws SQLException;
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 valueOf(String 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 object, String string);
98:
99: }
|