KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.ibatis.sqlmap.client.extensions.ParameterSetter;
19 import com.ibatis.sqlmap.client.extensions.ResultGetter;
20 import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
21
22 import java.sql.Blob JavaDoc;
23 import java.sql.SQLException JavaDoc;
24
25 public class BlobTypeHandlerCallback implements TypeHandlerCallback {
26
27  public Object JavaDoc getResult(ResultGetter getter) throws SQLException JavaDoc {
28    Blob JavaDoc blob = getter.getBlob();
29    byte[] returnValue = null;
30    if (null != blob) {
31      returnValue = blob.getBytes(1, (int) blob.length());
32    } else {
33      returnValue = null;
34    }
35    return returnValue;
36  }
37
38  public void setParameter(ParameterSetter setter, Object JavaDoc parameter)
39 throws SQLException JavaDoc {
40    if (null != parameter) {
41      byte[] bytes = (byte[]) parameter;
42      setter.setBytes(bytes);
43    }
44  }
45
46  public Object JavaDoc valueOf(String JavaDoc s) {
47    return s;
48  }
49
50 }
Popular Tags