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: * String implementation of TypeHandler
25: */
26: public class StringTypeHandler extends BaseTypeHandler implements
27: TypeHandler {
28:
29: public void setParameter(PreparedStatement ps, int i,
30: Object parameter, String jdbcType) throws SQLException {
31: ps.setString(i, ((String) parameter));
32: }
33:
34: public Object getResult(ResultSet rs, String columnName)
35: throws SQLException {
36: Object s = rs.getString(columnName);
37: if (rs.wasNull()) {
38: return null;
39: } else {
40: return s;
41: }
42: }
43:
44: public Object getResult(ResultSet rs, int columnIndex)
45: throws SQLException {
46: Object s = rs.getString(columnIndex);
47: if (rs.wasNull()) {
48: return null;
49: } else {
50: return s;
51: }
52: }
53:
54: public Object getResult(CallableStatement cs, int columnIndex)
55: throws SQLException {
56: Object s = cs.getString(columnIndex);
57: if (cs.wasNull()) {
58: return null;
59: } else {
60: return s;
61: }
62: }
63:
64: public Object valueOf(String s) {
65: return s;
66: }
67:
68: }
|