01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.type;
10:
11: import java.sql.Clob;
12: import java.sql.SQLException;
13:
14: /**
15: * @author Gennady Krizhevsky
16: */
17: public class ClobStringHandler extends ClobTypeHandler {
18:
19: public Object transformRead(Object data) throws SQLException {
20: if (data != null) {
21: if (data instanceof Clob) {
22: return ((Clob) data).getSubString(1,
23: (int) ((Clob) data).length());
24: } else if (data instanceof String) {
25: return data;
26: } else {
27: throw new ClassCastException("Cannot read Clob from "
28: + data);
29: }
30: }
31: return null;
32: }
33: }
|