View Javadoc

1   package net.sourceforge.mavenplugins.dbunit;
2   
3   import org.dbunit.dataset.DataSetException;
4   
5   import java.io.FileNotFoundException;
6   import java.io.IOException;
7   
8   /* ====================================================================
9    * The Apache Software License, Version 1.1
10   *
11   * Copyright (c) 2002 The Apache Software Foundation.  All rights
12   * reserved.
13   *
14   * Redistribution and use in source and binary forms, with or without
15   * modification, are permitted provided that the following conditions
16   * are met:
17   *
18   * 1. Redistributions of source code must retain the above copyright
19   *    notice, this list of conditions and the following disclaimer.
20   *
21   * 2. Redistributions in binary form must reproduce the above copyright
22   *    notice, this list of conditions and the following disclaimer in
23   *    the documentation and/or other materials provided with the
24   *    distribution.
25   *
26   * 3. The end-user documentation included with the redistribution,
27   *    if any, must include the following acknowledgment:
28   *       "This product includes software developed by the
29   *        Apache Software Foundation (http://www.apache.org/)."
30   *    Alternately, this acknowledgment may appear in the software itself,
31   *    if and wherever such third-party acknowledgments normally appear.
32   *
33   * 4. The names "Apache" and "Apache Software Foundation" and
34   *    "Apache Maven" must not be used to endorse or promote products
35   *    derived from this software without prior written permission. For
36   *    written permission, please contact apache@apache.org.
37   *
38   * 5. Products derived from this software may not be called "Apache",
39   *    "Apache Maven", nor may "Apache" appear in their name, without
40   *    prior written permission of the Apache Software Foundation.
41   *
42   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
43   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
46   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
49   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
51   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
52   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53   * SUCH DAMAGE.
54   * ====================================================================
55   *
56   * This software consists of voluntary contributions made by many
57   * individuals on behalf of the Apache Software Foundation.  For more
58   * information on the Apache Software Foundation, please see
59   * <http://www.apache.org/>.
60   *
61   * ====================================================================
62   */
63  
64  /**
65   * @author Dion Gillard
66   */
67  public class DataSetConverter extends DbUnitTool
68  {
69  
70      /** format of the input dataset */
71      private String inputFormat;
72      /** format of the output dataset */
73      private String outputFormat;
74      /** file name for input */
75      private String input;
76      /** file name for output */
77      private String output;
78      
79      /**
80       * Convert the input dataset to the output dataset
81       * @throws IOException
82       * @throws FileNotFoundException
83       * @throws DataSetException
84       */
85      public void process() throws DataSetException, FileNotFoundException, IOException
86      {
87          writeDataSetToFile(getOutput(), getOutputFormat(), getDataSetFromFile(getInput(), getInputFormat()));
88      }
89      
90      /**
91       * @return Returns the input.
92       */
93      public String getInput()
94      {
95          return input;
96      }
97      /**
98       * @param input The input to set.
99       */
100     public void setInput(String input)
101     {
102         this.input = input;
103     }
104     /**
105      * @return Returns the inputFormat.
106      */
107     public String getInputFormat()
108     {
109         return inputFormat;
110     }
111     /**
112      * @param inputFormat The inputFormat to set.
113      */
114     public void setInputFormat(String inputFormat)
115     {
116         this.inputFormat = inputFormat;
117     }
118     /**
119      * @return Returns the output.
120      */
121     public String getOutput()
122     {
123         return output;
124     }
125     /**
126      * @param output The output to set.
127      */
128     public void setOutput(String output)
129     {
130         this.output = output;
131     }
132     /**
133      * @return Returns the outputFormat.
134      */
135     public String getOutputFormat()
136     {
137         return outputFormat;
138     }
139     /**
140      * @param outputFormat The outputFormat to set.
141      */
142     public void setOutputFormat(String outputFormat)
143     {
144         this.outputFormat = outputFormat;
145     }
146 }