DefaultTableMetaData.java

  1. /*
  2.  *
  3.  * The DbUnit Database Testing Framework
  4.  * Copyright (C)2002-2004, 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.dataset;

  22. import java.util.Arrays;


  23. /**
  24.  * @author Manuel Laflamme
  25.  * @version $Revision$
  26.  * @since Feb 17, 2002
  27.  */
  28. public class DefaultTableMetaData extends AbstractTableMetaData
  29. {

  30.     private final String _tableName;
  31.     private final Column[] _columns;
  32.     private final Column[] _primaryKeys;

  33.     public DefaultTableMetaData(String tableName, Column[] columns)
  34.             //throws DataSetException
  35.     {
  36.         this(tableName, columns, new String[0]);
  37.     }

  38.     public DefaultTableMetaData(String tableName, Column[] columns,
  39.             String[] primaryKeys) //throws DataSetException
  40.     {
  41.         _tableName = tableName;
  42.         _columns = columns;
  43.         _primaryKeys = Columns.getColumns(primaryKeys, columns);
  44.     }

  45.     public DefaultTableMetaData(String tableName, Column[] columns,
  46.             Column[] primaryKeys) //throws DataSetException
  47.     {
  48.         _tableName = tableName;
  49.         _columns = columns;
  50.         _primaryKeys = primaryKeys;
  51.     }

  52.     public String toString()
  53.     {
  54.         return "tableName=" + _tableName +
  55.                 ", columns=" + Arrays.asList(_columns) +
  56.                 ", keys=" + Arrays.asList(_primaryKeys) + "";
  57.     }

  58.     ////////////////////////////////////////////////////////////////////////////
  59.     // ITableMetaData interface

  60.     public String getTableName()
  61.     {
  62.         return _tableName;
  63.     }

  64.     public Column[] getColumns()
  65.     {
  66.         return _columns;
  67.     }

  68.     public Column[] getPrimaryKeys()
  69.     {
  70.         return _primaryKeys;
  71.     }
  72. }