SqlLoaderControlDataSet.java

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

  22. import java.io.File;
  23. import java.util.List;

  24. import org.dbunit.dataset.CachedDataSet;
  25. import org.dbunit.dataset.DataSetException;
  26. import org.dbunit.dataset.IDataSet;

  27. /**
  28.  * This class constructs an {@link IDataSet} given a directory containing control
  29.  * files. It handles translations of "null"(the string), into null.
  30.  * <p>
  31.  * Example usage:
  32.  * <code><pre>
  33.  * File ctlDir = new File("src/sqlloader");
  34.  * File orderedTablesFile = new File("src/sqlloader/tables.lst");
  35.  * IDataSet dataSet = new SqlLoaderControlDataSet(ctlDir, orderedTablesFile);
  36.  * </pre></code>
  37.  * The file <code>orderedTablesFile</code> must contain the names of the tables to
  38.  * be imported. As a convention the .ctl file must have the same name as the table names file.
  39.  * Here an example of the &quot;tables.lst&quot; file:
  40.  * <br>
  41.  * <table border="1">
  42.  * <tr><td>LANGUAGE<br>COUNTRY</td></tr>
  43.  * </table>
  44.  * The <code>ctlDir</code> directory must then contain the files <code>COUNTRY.ctl</code>
  45.  * and <code>LANGUAGE.ctl</code>.
  46.  * </p>
  47.  *
  48.  * @author Stephan Strittmatter (stritti AT users.sourceforge.net), gommma (gommma AT users.sourceforge.net)
  49.  * @author Last changed by: $Author$
  50.  * @version $Revision$ $Date$
  51.  * @since 2.4.0
  52.  */
  53. public class SqlLoaderControlDataSet extends CachedDataSet implements IDataSet {

  54.     /**
  55.      * The Constructor.
  56.      *
  57.      * @param ctlDir the control files directory
  58.      * @param orderedTablesFile the table order file
  59.      *
  60.      * @throws DataSetException the data set exception
  61.      */
  62.     public SqlLoaderControlDataSet(String ctlDir, String orderedTablesFile)
  63.     throws DataSetException
  64.     {
  65.         super(new SqlLoaderControlProducer(ctlDir, orderedTablesFile));
  66.     }

  67.     /**
  68.      * The Constructor.
  69.      *
  70.      * @param ctlDir the control files directory
  71.      * @param orderedTablesFile the table order file
  72.      *
  73.      * @throws DataSetException the data set exception
  74.      */
  75.     public SqlLoaderControlDataSet(File ctlDir, File orderedTablesFile)
  76.     throws DataSetException
  77.     {
  78.         super(new SqlLoaderControlProducer(ctlDir, orderedTablesFile));
  79.     }
  80.    
  81.     /**
  82.      * The Constructor.
  83.      *
  84.      * @param ctlDir the control files directory
  85.      * @param orderedTableNames a list of strings that contains the ordered table names
  86.      *
  87.      * @throws DataSetException the data set exception
  88.      */
  89.     public SqlLoaderControlDataSet(File ctlDir, List orderedTableNames)
  90.     throws DataSetException
  91.     {
  92.         super(new SqlLoaderControlProducer(ctlDir, orderedTableNames));
  93.     }

  94. }