01: /*
02: *
03: * The DbUnit Database Testing Framework
04: * Copyright (C)2002-2004, DbUnit.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: */
21:
22: package org.dbunit.ext.db2;
23:
24: import org.slf4j.Logger;
25: import org.slf4j.LoggerFactory;
26:
27: import org.dbunit.dataset.datatype.DataType;
28: import org.dbunit.dataset.datatype.DataTypeException;
29: import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
30: import org.dbunit.dataset.datatype.StringDataType;
31:
32: import java.sql.Types;
33:
34: /**
35: * Specialized factory that recognizes DB2 data types.
36: *
37: * @author Federico Spinazzi
38: * @author Manuel Laflamme
39: * @since Jul 17, 2003
40: * @version $Revision: 554 $
41: */
42: public class Db2DataTypeFactory extends DefaultDataTypeFactory {
43:
44: /**
45: * Logger for this class
46: */
47: private static final Logger logger = LoggerFactory
48: .getLogger(Db2DataTypeFactory.class);
49:
50: static final DataType DB2XML_XMLVARCHAR = new StringDataType(
51: "DB2XML.XMLVARCHAR", Types.DISTINCT);
52: static final DataType DB2XML_XMLCLOB = new StringDataType(
53: "DB2XML.XMLCLOB", Types.DISTINCT);
54: static final DataType DB2XML_XMLFILE = new StringDataType(
55: "DB2XML.XMLFILE", Types.DISTINCT);
56:
57: public DataType createDataType(int sqlType, String sqlTypeName)
58: throws DataTypeException {
59: logger.debug("createDataType(sqlType=" + sqlType
60: + ", sqlTypeName=" + sqlTypeName + ") - start");
61:
62: if (sqlType == Types.DISTINCT) {
63: if (sqlTypeName.equals(DB2XML_XMLVARCHAR.toString())) {
64: return DB2XML_XMLVARCHAR;
65: }
66:
67: if (sqlTypeName.equals(DB2XML_XMLCLOB.toString())) {
68: return DB2XML_XMLCLOB;
69: }
70:
71: if (sqlTypeName.equals(DB2XML_XMLFILE.toString())) {
72: return DB2XML_XMLFILE;
73: }
74: }
75:
76: return super.createDataType(sqlType, sqlTypeName);
77: }
78: }
|