KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > command > lib > CompilerGeneratorBase


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, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.command.lib;
28
29 // Package dependencies.
30
import org.objectweb.openccm.command.api.Generator;
31 import org.objectweb.util.cmdline.api.CommandLine;
32 import org.objectweb.util.cmdline.api.OptionArgument;
33 import org.objectweb.util.cmdline.lib.DefaultOptionArgument;
34
35 /**
36  * Abstract base class for all compilers/generators.
37  *
38  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
39  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
40  *
41  * @version 0.2
42  */

43
44 public abstract class CompilerGeneratorBase
45               extends CompilerBase
46            implements Generator
47 {
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53

54     /** The output filename option. */
55     private OptionArgument ofile_; // -o <file>
56

57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      * The constructor with the command line manager and the default
65      * output file name.
66      *
67      * @param commandLine The command line manager.
68      * @param filename The default output file name.
69      */

70     public
71     CompilerGeneratorBase(CommandLine commandLine,
72                           String JavaDoc filename)
73     {
74         // Calls the CompilerBase constructor.
75
super(commandLine);
76
77         // Inits internal state.
78
ofile_ = new DefaultOptionArgument(
79                         "-o",
80                         "outputfile",
81                         "Set the output file name, default is " + filename,
82                         filename);
83         commandLine.addOption(ofile_);
84     }
85
86     /**
87      * The constructor with the command line manager.
88      *
89      * @param commandLine The command line manager.
90      */

91     public
92     CompilerGeneratorBase(CommandLine commandLine)
93     {
94         // Calls the CompilerBase constructor.
95
super(commandLine);
96     }
97
98     // ==================================================================
99
//
100
// Internal methods.
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// Public methods for org.objectweb.util.cmdline.api.Application
107
//
108
// ==================================================================
109

110     // ==================================================================
111
//
112
// Public methods for org.objectweb.openccm.command.api.Application
113
//
114
// ==================================================================
115

116     // ==================================================================
117
//
118
// Public methods for org.objectweb.openccm.command.api.CommandOnIR3
119
//
120
// ==================================================================
121

122     // ==================================================================
123
//
124
// Public methods for org.objectweb.openccm.command.api.CommandOnAST
125
//
126
// ==================================================================
127

128     // ==================================================================
129
//
130
// Public methods for org.objectweb.openccm.command.api.Compiler
131
//
132
// ==================================================================
133

134     // ==================================================================
135
//
136
// Public methods for org.objectweb.openccm.command.api.Generator
137
//
138
// ==================================================================
139

140     /**
141      * Obtains the output file name.
142      *
143      * @result The output file name.
144      */

145     public String JavaDoc
146     getOutputFileName()
147     {
148         return ofile_.getArgument();
149     }
150
151     /**
152      * Indents a file.
153      *
154      * @param filename The file name to indent.
155      *
156      * @return True if ok, else false.
157      */

158     public boolean
159     indent(String JavaDoc inputfile)
160     {
161         org.objectweb.openccm.generator.common.lib.Indentor ind =
162             new org.objectweb.openccm.generator.common.lib.Indentor();
163         try
164         {
165             ind.indent(inputfile);
166         }
167         catch(java.io.IOException JavaDoc e)
168         {
169             getConsole().error("I/O Exception with file " + inputfile);
170             report_exception(e);
171             return false;
172         }
173         return true;
174     }
175
176     // ==================================================================
177
//
178
// Other public methods.
179
//
180
// ==================================================================
181
}
182
Popular Tags