View Javadoc
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  
23  import java.io.File;
24  import java.util.List;
25  
26  import org.dbunit.dataset.CachedDataSet;
27  import org.dbunit.dataset.DataSetException;
28  import org.dbunit.dataset.IDataSet;
29  
30  /**
31   * This class constructs an {@link IDataSet} given a directory containing control
32   * files. It handles translations of "null"(the string), into null.
33   * <p>
34   * Example usage:
35   * <code><pre>
36   * File ctlDir = new File("src/sqlloader");
37   * File orderedTablesFile = new File("src/sqlloader/tables.lst");
38   * IDataSet dataSet = new SqlLoaderControlDataSet(ctlDir, orderedTablesFile);
39   * </pre></code>
40   * The file <code>orderedTablesFile</code> must contain the names of the tables to
41   * be imported. As a convention the .ctl file must have the same name as the table names file.
42   * Here an example of the &quot;tables.lst&quot; file:
43   * <br>
44   * <table border="1">
45   * <tr><td>LANGUAGE<br>COUNTRY</td></tr>
46   * </table>
47   * The <code>ctlDir</code> directory must then contain the files <code>COUNTRY.ctl</code>
48   * and <code>LANGUAGE.ctl</code>.
49   * </p>
50   * 
51   * @author Stephan Strittmatter (stritti AT users.sourceforge.net), gommma (gommma AT users.sourceforge.net)
52   * @author Last changed by: $Author$
53   * @version $Revision$ $Date$
54   * @since 2.4.0
55   */
56  public class SqlLoaderControlDataSet extends CachedDataSet implements IDataSet {
57  
58      /**
59       * The Constructor.
60       * 
61       * @param ctlDir the control files directory
62       * @param orderedTablesFile the table order file
63       * 
64       * @throws DataSetException the data set exception
65       */
66      public SqlLoaderControlDataSet(String ctlDir, String orderedTablesFile) 
67      throws DataSetException 
68      {
69          super(new SqlLoaderControlProducer(ctlDir, orderedTablesFile));
70      }
71  
72      /**
73       * The Constructor.
74       * 
75       * @param ctlDir the control files directory
76       * @param orderedTablesFile the table order file
77       * 
78       * @throws DataSetException the data set exception
79       */
80      public SqlLoaderControlDataSet(File ctlDir, File orderedTablesFile) 
81      throws DataSetException 
82      {
83          super(new SqlLoaderControlProducer(ctlDir, orderedTablesFile));
84      }
85      
86      /**
87       * The Constructor.
88       * 
89       * @param ctlDir the control files directory
90       * @param orderedTableNames a list of strings that contains the ordered table names
91       * 
92       * @throws DataSetException the data set exception
93       */
94      public SqlLoaderControlDataSet(File ctlDir, List orderedTableNames) 
95      throws DataSetException 
96      {
97          super(new SqlLoaderControlProducer(ctlDir, orderedTableNames));
98      }
99  
100 }