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.util.fileloader;
22  
23  import java.io.IOException;
24  import java.net.URL;
25  import java.util.Map;
26  
27  import org.dbunit.DatabaseUnitRuntimeException;
28  import org.dbunit.dataset.DataSetException;
29  import org.dbunit.dataset.IDataSet;
30  
31  /**
32   * Defines a dbUnit data file loader supporting replacement objects and
33   * substrings with {@link org.dbunit.dataset.ReplacementDataSet}.
34   * 
35   * @author Jeff Jensen jeffjensen AT users.sourceforge.net
36   * @author Last changed by: $Author$
37   * @version $Revision$ $Date$
38   * @since 2.4.8
39   */
40  public interface DataFileLoader {
41      /**
42       * Load the specified String filename from the classpath into a dbUnit
43       * dataset. If filename == null or "", then returns an empty
44       * {@link org.dbunit.dataset.DefaultDataSet}. The type of dbUnit dataset
45       * created is delegated to the implementing subclass.
46       * 
47       * @param filename
48       *            The dbUnit file to load, in the format for the loader
49       *            implementation and fully qualified name with package syntax.
50       * @return The dbUnit dataset of the specified file.
51       * @throws DatabaseUnitRuntimeException
52       *             DataSetException wrapped in a DatabaseUnitRuntimeException
53       *             when file load errors occur.
54       */
55      IDataSet load(String fileName);
56  
57      /**
58       * Load the specified URL file into a dbUnit dataset. The type of dbUnit
59       * dataset created is delegated to the implementing subclass.
60       * 
61       * @param url
62       *            The dbUnit data file url.
63       * @return dbUnit dataset of the corresponding input file type.
64       * @throws DataSetException
65       *             On data errors.
66       * @throws IOException
67       *             On file errors.
68       * @since 2.4.8
69       */
70      IDataSet loadDataSet(URL url) throws DataSetException, IOException;
71  
72      /**
73       * Add the specified replacement objects to existing ones for use with
74       * {@link org.dbunit.dataset.ReplacementDataSet}.
75       * 
76       * @param replacementObjects
77       *            The replacement objects to include.
78       * @since 2.4.8
79       */
80      void addReplacementObjects(Map replacementObjects);
81  
82      /**
83       * Add the specified replacement substrings to existing ones for use with
84       * {@link org.dbunit.dataset.ReplacementDataSet}.
85       * 
86       * @param replacementSubstrings
87       *            The replacement substrings to include.
88       * @since 2.4.8
89       */
90      void addReplacementSubstrings(Map replacementSubstrings);
91  
92      /**
93       * Remove all existing replacement objects, resetting to none so no object
94       * replacements occur.
95       * 
96       * @since 2.4.8
97       */
98      void removeAllReplacementObjects();
99  
100     /**
101      * Remove all existing replacement substring objects, resetting to none so
102      * no substring replacements occur.
103      * 
104      * @since 2.4.8
105      */
106     void removeAllReplacementSubstrings();
107 }