View Javadoc
1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2002-2009, DbUnit.org
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * 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  package org.dbunit.ext.netezza;
22  
23  import org.dbunit.dataset.datatype.DataType;
24  import org.dbunit.dataset.datatype.DataTypeException;
25  import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  
29  /**
30   * NetezzaDataTypeFactory - This class is for the DBUnit data type factory for Netezza database
31   * 
32   * @author Ameet (amit3011 AT users.sourceforge.net)
33   * @author Last changed by: $Author$
34   * @version $Revision$ $Date$
35   * @since 2.4.6
36   */
37  public class NetezzaDataTypeFactory extends DefaultDataTypeFactory
38  {
39  
40  	/**
41  	 * Logger for this class
42  	 */
43  	private static final Logger logger = LoggerFactory.getLogger(NetezzaDataTypeFactory.class);
44  
45  	public static final int RECADDR = 1;
46  	public static final int NUMERIC = 2;
47  	public static final int DECIMAL = 3;
48  	public static final int INTEGER = 4;
49  	public static final int SMALLINT = 5;
50  	public static final int DOUBLE = 8;
51  	public static final int INTERVAL = 10;
52  	public static final int BOOLEAN = -7;
53  	public static final int CHAR = -1;
54  	public static final int FLOAT = 6;
55  	public static final int REAL = 7;
56  	public static final int VARCHAR = 12;
57  	public static final int DATE = 91;
58  	public static final int TIME = 92;
59  	public static final int TIMESTAMP = 93;
60  	public static final int TIMETZ = 1266;
61  	public static final int UNKNOWN = 18;
62  	public static final int BYTEINT = -6;
63  	public static final int INT8 = 20;
64  	public static final int VARFIXEDCHAR = 21;
65  	public static final int NUCL = 22;
66  	public static final int PROT = 23;
67  	public static final int BLOB = 24;
68  	public static final int BIGINT = -5;
69  	public static final int NCHAR = -8;
70  	public static final int NVARCHAR = -9;
71  	public static final int NTEXT = 27;
72  
73  	public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException
74  	{
75  		if (logger.isDebugEnabled())
76  			logger.debug("createDataType(sqlType={}, sqlTypeName={}) - start", String.valueOf(sqlType), sqlTypeName);
77  
78  		switch (sqlType)
79  		{
80  			case RECADDR:
81  				return DataType.VARCHAR;
82  
83  			case INTEGER:
84  				return DataType.INTEGER;
85  
86  			case INTERVAL:
87  				return DataType.TIMESTAMP;
88  			case TIMETZ:
89  				return DataType.TIMESTAMP;
90  			case BOOLEAN:
91  				return DataType.BOOLEAN;
92  			case SMALLINT:
93  				return DataType.SMALLINT;
94  
95  			case REAL:
96  				return DataType.FLOAT;
97  			case BYTEINT:
98  				return DataType.INTEGER;
99  			case INT8:
100 				return DataType.BIGINT;
101 			case VARFIXEDCHAR:
102 				return DataType.CHAR;
103 			case NUCL:
104 				return DataType.CHAR;
105 			case PROT:
106 				return DataType.CHAR;
107 			case DATE:
108 				return DataType.DATE;
109 			case BLOB:
110 				return DataType.BLOB;
111 			case NCHAR:
112 				return DataType.CHAR;
113 			case NVARCHAR:
114 				return DataType.VARCHAR;
115 			case NTEXT:
116 				return DataType.LONGVARCHAR;
117 			case VARCHAR:
118 				return DataType.VARCHAR;
119 			default:
120 				return super.createDataType(sqlType, sqlTypeName);
121 		}
122 	}
123 }
124 
125