KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > corba > idl2java > IdlToJavaApplicationBase


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2005 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): Philippe Merle.
24
25 ====================================================================
26 $Id: IdlToJavaApplicationBase.java,v 1.2 2005/07/06 11:47:50 merle Exp $
27 ====================================================================*/

28
29 package org.objectweb.openccm.corba.idl2java;
30
31 // Package dependencies.
32
import org.objectweb.util.cmdline.api.CommandLine;
33 import org.objectweb.util.cmdline.api.OptionArgument;
34 import org.objectweb.util.cmdline.api.OptionArguments;
35 import org.objectweb.util.cmdline.lib.ApplicationBase;
36 import org.objectweb.util.cmdline.lib.DefaultCommandLine;
37 import org.objectweb.util.cmdline.lib.DefaultOptionArgument;
38 import org.objectweb.util.cmdline.lib.DefaultOptionArguments;
39
40 import org.objectweb.openccm.command.lib.ReleaseInfo;
41
42 /**
43  * Base class for an IDL to Java application.
44  * This class manages the command line.
45  *
46  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
47  *
48  * @version 0.1
49  */

50 public abstract class IdlToJavaApplicationBase
51               extends ApplicationBase
52            implements IdlToJavaOperations
53 {
54     // ==================================================================
55
//
56
// Internal state.
57
//
58
// ==================================================================
59

60     /** The output filename option. */
61     protected OptionArgument destdir_opt_; // -d <destdir>
62

63     /** The Preprocessor include option. */
64     protected PreprocessorOption include_opt_; // -IDIR
65

66     /** The package mapping option. */
67     protected OptionArguments i2jpackage_opt_; // -i2jpackage x:a.b
68

69     // ==================================================================
70
//
71
// Constructors.
72
//
73
// ==================================================================
74

75     /**
76      * The default constructor.
77      */

78     public
79     IdlToJavaApplicationBase()
80     {
81         this(new DefaultCommandLine("idl2java",
82                                     "omg_idl_file",
83                                     "Generate Java Mapping from an OMG IDL 2.0 file.",
84                                     true),
85              true);
86     }
87
88     /**
89      * The constructor with a provided command line manager.
90      *
91      * @param commandLine The provided command line manager.
92      * @param withDefaultOptions True to add default options in the command line.
93      */

94     public IdlToJavaApplicationBase(CommandLine commandLine,
95                                     boolean withDefaultOptions)
96     {
97         this(commandLine,withDefaultOptions,true);
98     }
99
100     /**
101      * The constructor with a provided command line manager.
102      *
103      * @param commandLine The provided command line manager.
104      * @param withDefaultOptions True to add default options in the command line.
105      * @param withPreprocessorOptions True to add preprocessor options in the command line.
106      */

107     public IdlToJavaApplicationBase(CommandLine commandLine,
108                                     boolean withDefaultOptions,
109                                     boolean withPreprocessorOptions)
110     {
111         // Calls the default ApplicationBase constructor.
112
super(commandLine, withDefaultOptions);
113
114         // Add the destination directory option
115
destdir_opt_ = new DefaultOptionArgument(
116                             "-d",
117                             "destdir",
118                             "Set the destination directory name, default is .",
119                             ".");
120         commandLine.addOption(destdir_opt_);
121         
122         // Add the include directory option
123
include_opt_ = new OptionIDIR(this);
124         commandLine.addOption(include_opt_);
125         
126         // Add the package mapping option
127
i2jpackage_opt_ = new DefaultOptionArguments(
128                             "-i2jpackage",
129                             "idl.module:java.pkg",
130                             "Define the target Java package for an OMG IDL module");
131         commandLine.addOption(i2jpackage_opt_);
132     }
133
134     // ==================================================================
135
//
136
// Internal methods.
137
//
138
// ==================================================================
139

140     // ==================================================================
141
//
142
// Public methods for org.objectweb.util.api.Identifiable
143
//
144
// ==================================================================
145

146     /**
147      * Obtains its identity.
148      *
149      * Should be defined in subclasses.
150      *
151      * @return Its identity.
152      */

153     public String JavaDoc
154     getIdentity()
155     {
156         return getCommandLine().getLabels()[0]
157              + ' ' + ReleaseInfo.VERSION;
158     }
159
160     // ==================================================================
161
//
162
// Public methods for org.objectweb.util.cmdline.api.Application
163
//
164
// ==================================================================
165

166     /**
167      * Obtains the associated version information.
168      *
169      * @return The associated version information.
170      */

171     public String JavaDoc[]
172     getVersionInformation()
173     {
174         String JavaDoc[] result = super.getVersionInformation();
175         result[0] = ReleaseInfo.NAME_SHORT + ' '
176                   + getIdentity()
177                   + " (on top of "
178                   + System.getProperty("orb.name", "UNKNOWN")
179                   + ' '
180                   + System.getProperty("orb.version", "X.X")
181                   + ')';
182         return result;
183     }
184
185     // ==================================================================
186
//
187
// Public methods
188
//
189
// ==================================================================
190

191 }
192
Popular Tags