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 com.ibatis.sqlmap.client.extensions.*;
19:
20: import java.io.StringReader;
21: import java.sql.*;
22:
23: public class ClobTypeHandlerCallback implements TypeHandlerCallback {
24:
25: public Object getResult(ResultGetter getter) throws SQLException {
26: String value = "";
27: Clob clob = getter.getClob();
28: if (clob != null) {
29: int size = (int) clob.length();
30: value = clob.getSubString(1, size);
31: }
32: return value;
33: }
34:
35: public void setParameter(ParameterSetter setter, Object parameter)
36: throws SQLException {
37: String s = (String) parameter;
38: if (s != null) {
39: StringReader reader = new StringReader(s);
40: setter.setCharacterStream(reader, s.length());
41: } else {
42: setter.setString(null);
43: }
44: }
45:
46: public Object valueOf(String s) {
47: return s;
48: }
49:
50: }
|