• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2  *
3  * This program and the accompanying materials are made available under
4  * the terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * $Id: mergeTask.java,v 1.1.1.1.2.1 2004/07/08 10:52:09 vlad_r Exp $
8  */
9 package com.vladium.emma.data;
10 
11 import java.io.File;
12 
13 import org.apache.tools.ant.BuildException;
14 
15 import com.vladium.emma.ant.FileTask;
16 import com.vladium.emma.ant.SuppressableTask;
17 
18 // ----------------------------------------------------------------------------
19 /**
20  * @author Vlad Roubtsov, (C) 2003
21  */
22 public
23 final class mergeTask extends FileTask
24 {
25     // public: ................................................................
26 
27 
mergeTask(final SuppressableTask parent)28     public mergeTask (final SuppressableTask parent)
29     {
30         super (parent);
31     }
32 
execute()33     public void execute () throws BuildException
34     {
35         if (isEnabled ())
36         {
37             String [] files = getDataPath (true);
38             if ((files == null) || (files.length == 0))
39                 throw (BuildException) newBuildException (getTaskName ()
40                     + ": no valid input data files have been specified", location).fillInStackTrace ();
41 
42             final MergeProcessor processor = MergeProcessor.create ();
43 
44             processor.setDataPath (files); files = null;
45             processor.setSessionOutFile (m_outFile != null ? m_outFile.getAbsolutePath () : null);
46             processor.setPropertyOverrides (getTaskSettings ());
47 
48             processor.run ();
49         }
50     }
51 
52 
53     // mergefile|tofile|outfile|file attribute:
54 
setMergefile(final File file)55     public void setMergefile (final File file)
56     {
57         if (m_outFile != null)
58             throw (BuildException) newBuildException (getTaskName ()
59                 + ": merge data file attribute already set", location).fillInStackTrace ();
60 
61         m_outFile = file;
62     }
63 
setOutfile(final File file)64     public void setOutfile (final File file)
65     {
66         if (m_outFile != null)
67             throw (BuildException) newBuildException (getTaskName ()
68                 + ": merge data file attribute already set", location).fillInStackTrace ();
69 
70         m_outFile = file;
71     }
72 
setTofile(final File file)73     public void setTofile (final File file)
74     {
75         if (m_outFile != null)
76             throw (BuildException) newBuildException (getTaskName ()
77                 + ": merge data file attribute already set", location).fillInStackTrace ();
78 
79         m_outFile = file;
80     }
81 
setFile(final File file)82     public void setFile (final File file)
83     {
84         if (m_outFile != null)
85             throw (BuildException) newBuildException (getTaskName ()
86                 + ": merge data file attribute already set", location).fillInStackTrace ();
87 
88         m_outFile = file;
89     }
90 
91 
92     // protected: .............................................................
93 
94     // package: ...............................................................
95 
96     // private: ...............................................................
97 
98 
99     private File m_outFile;
100 
101 } // end of class
102 // ----------------------------------------------------------------------------