NetezzaDataTypeFactory.java

  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. import org.dbunit.dataset.datatype.DataType;
  23. import org.dbunit.dataset.datatype.DataTypeException;
  24. import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
  25. import org.slf4j.Logger;
  26. import org.slf4j.LoggerFactory;

  27. /**
  28.  * NetezzaDataTypeFactory - This class is for the DBUnit data type factory for Netezza database
  29.  *
  30.  * @author Ameet (amit3011 AT users.sourceforge.net)
  31.  * @author Last changed by: $Author$
  32.  * @version $Revision$ $Date$
  33.  * @since 2.4.6
  34.  */
  35. public class NetezzaDataTypeFactory extends DefaultDataTypeFactory
  36. {

  37.     /**
  38.      * Logger for this class
  39.      */
  40.     private static final Logger logger = LoggerFactory.getLogger(NetezzaDataTypeFactory.class);

  41.     public static final int RECADDR = 1;
  42.     public static final int NUMERIC = 2;
  43.     public static final int DECIMAL = 3;
  44.     public static final int INTEGER = 4;
  45.     public static final int SMALLINT = 5;
  46.     public static final int DOUBLE = 8;
  47.     public static final int INTERVAL = 10;
  48.     public static final int BOOLEAN = -7;
  49.     public static final int CHAR = -1;
  50.     public static final int FLOAT = 6;
  51.     public static final int REAL = 7;
  52.     public static final int VARCHAR = 12;
  53.     public static final int DATE = 91;
  54.     public static final int TIME = 92;
  55.     public static final int TIMESTAMP = 93;
  56.     public static final int TIMETZ = 1266;
  57.     public static final int UNKNOWN = 18;
  58.     public static final int BYTEINT = -6;
  59.     public static final int INT8 = 20;
  60.     public static final int VARFIXEDCHAR = 21;
  61.     public static final int NUCL = 22;
  62.     public static final int PROT = 23;
  63.     public static final int BLOB = 24;
  64.     public static final int BIGINT = -5;
  65.     public static final int NCHAR = -8;
  66.     public static final int NVARCHAR = -9;
  67.     public static final int NTEXT = 27;

  68.     public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException
  69.     {
  70.         if (logger.isDebugEnabled())
  71.             logger.debug("createDataType(sqlType={}, sqlTypeName={}) - start", String.valueOf(sqlType), sqlTypeName);

  72.         switch (sqlType)
  73.         {
  74.             case RECADDR:
  75.                 return DataType.VARCHAR;

  76.             case INTEGER:
  77.                 return DataType.INTEGER;

  78.             case INTERVAL:
  79.                 return DataType.TIMESTAMP;
  80.             case TIMETZ:
  81.                 return DataType.TIMESTAMP;
  82.             case BOOLEAN:
  83.                 return DataType.BOOLEAN;
  84.             case SMALLINT:
  85.                 return DataType.SMALLINT;

  86.             case REAL:
  87.                 return DataType.FLOAT;
  88.             case BYTEINT:
  89.                 return DataType.INTEGER;
  90.             case INT8:
  91.                 return DataType.BIGINT;
  92.             case VARFIXEDCHAR:
  93.                 return DataType.CHAR;
  94.             case NUCL:
  95.                 return DataType.CHAR;
  96.             case PROT:
  97.                 return DataType.CHAR;
  98.             case DATE:
  99.                 return DataType.DATE;
  100.             case BLOB:
  101.                 return DataType.BLOB;
  102.             case NCHAR:
  103.                 return DataType.CHAR;
  104.             case NVARCHAR:
  105.                 return DataType.VARCHAR;
  106.             case NTEXT:
  107.                 return DataType.LONGVARCHAR;
  108.             case VARCHAR:
  109.                 return DataType.VARCHAR;
  110.             default:
  111.                 return super.createDataType(sqlType, sqlTypeName);
  112.         }
  113.     }
  114. }

  115.