KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > task > Idl2JavaApplication


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.task;
28
29 // Package dependencies.
30
import java.util.ArrayList JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.StringTokenizer JavaDoc;
34
35
36 /**
37  * This class configure a standard launcher application to run an idl2java command.
38  *
39  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
40  *
41  * @version 0.1
42  */

43 public class Idl2JavaApplication
44      extends LauncherApplication
45 {
46     // ==================================================================
47
//
48
// Internal states.
49
//
50
// ==================================================================
51

52     /** The file to parse. */
53     protected String JavaDoc file_;
54
55     /** The destination directory. */
56     protected String JavaDoc destdir_;
57
58     /** The directory list to add to the search path. */
59     protected String JavaDoc includes_;
60
61     /** Ordered list of Mapping elements. */
62     protected List JavaDoc mapping_elements_;
63
64     // ==================================================================
65
//
66
// Constructors.
67
//
68
// ==================================================================
69

70     /**
71      * The default constructor.
72      */

73     public Idl2JavaApplication()
74     {
75         // Init internal states
76
file_ = null;
77         destdir_ = null;
78         includes_ = null;
79         mapping_elements_ = new ArrayList JavaDoc();
80     }
81     
82     // ==================================================================
83
//
84
// Internal methods.
85
//
86
// ==================================================================
87

88     // ==================================================================
89
//
90
// Public methods.
91
//
92
// ==================================================================
93

94     /**
95      * Set the file to parse.
96      *
97      * @param file - The file name.
98      */

99     public void
100     setFile(String JavaDoc file)
101     {
102         file_ = file;
103     }
104
105     /**
106      * Set the destination directory.
107      *
108      * @param dir - The directory name.
109      */

110     public void
111     setDestdir(String JavaDoc dir)
112     {
113         destdir_ = dir;
114     }
115
116     /**
117      * Set a directory list to add to the search path.
118      *
119      * @param dirs - A directory list.
120      */

121     public void
122     setIncludes(String JavaDoc dirs)
123     {
124         includes_ = dirs;
125     }
126
127     /**
128      * Create an inner element for Package Mapping.
129      */

130     public PackageMapping
131     createMapping()
132     {
133         PackageMapping mapping = null;
134         
135         mapping = new PackageMapping();
136         // Add to ordered list
137
mapping_elements_.add(mapping);
138                 
139         return mapping;
140     }
141     
142     /**
143      * Configure the task.
144      */

145     public void
146     configure()
147     {
148         StringTokenizer JavaDoc st = null;
149         
150         setXmlFile( project_properties_.getProperty("OpenCCM_HOMEDIR") + "/xml/launcher/IdlToJava.xml" );
151         
152         // Add the destination directory
153
if (destdir_ != null)
154         {
155             addArgument("-d");
156             addArgument(destdir_);
157         }
158             
159        // Add includes
160
if (includes_ != null)
161        {
162            st = new StringTokenizer JavaDoc(includes_, ",");
163            while (st.hasMoreTokens())
164            {
165                addArgument( "-I" + st.nextToken().trim() );
166            }
167        }
168        
169        // Add package mappings
170
for (Iterator JavaDoc it = mapping_elements_.iterator(); it.hasNext();)
171        {
172            addArgument("-i2jpackage");
173            addArgument( ((PackageMapping) it.next()).asArgument() );
174        }
175        
176        // Add the file to parse
177
addArgument(file_);
178     }
179 }
180
Popular Tags