View Javadoc

1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2008, 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.h2;
22  
23  import java.util.Arrays;
24  import java.util.Collection;
25  
26  import java.util.Arrays;
27  import java.util.Collection;
28  
29  import java.util.Arrays;
30  import java.util.Collection;
31  
32  import java.util.Arrays;
33  import java.util.Collection;
34  
35  import org.dbunit.dataset.datatype.DataType;
36  import org.dbunit.dataset.datatype.DataTypeException;
37  import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
38  import org.slf4j.Logger;
39  import org.slf4j.LoggerFactory;
40  
41  /**
42   * Specialized factory that recognizes H2 data types.
43   *
44   * @author Felipe Leme
45   * @author Last changed by: $Author: gommma $
46   * @version $Revision: 1031 $ $Date: 2009-09-12 17:13:43 +0200 (sab, 12 set 2009) $
47   * @since 2.2.1
48   */
49  public class H2DataTypeFactory extends DefaultDataTypeFactory
50  {
51  
52      /**
53       * Logger for this class
54       */
55      private static final Logger logger = LoggerFactory.getLogger(H2DataTypeFactory.class);
56      /**
57       * Database product names supported.
58       */
59      private static final Collection DATABASE_PRODUCTS = Arrays.asList(new String[] {"h2"});
60  
61      /**
62       * @see org.dbunit.dataset.datatype.IDbProductRelatable#getValidDbProducts()
63       */
64      public Collection getValidDbProducts()
65      {
66        return DATABASE_PRODUCTS;
67      }
68  
69      public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException
70      {
71      	if(logger.isDebugEnabled())
72      		logger.debug("createDataType(sqlType={}, sqlTypeName={}) - start", String.valueOf(sqlType), sqlTypeName);
73  
74          if (sqlTypeName.equals("BOOLEAN"))
75          {
76              return DataType.BOOLEAN;
77          }
78  
79          return super.createDataType(sqlType, sqlTypeName);
80      }
81  }