KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 GeneratorBase
45               extends CommandOnASTBase
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     GeneratorBase(CommandLine commandLine,
72                   String JavaDoc filename)
73     {
74         // Calls the CommandOnASTBase 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
//
88
// Internal methods.
89
//
90
// ==================================================================
91

92     // ==================================================================
93
//
94
// Public methods for org.objectweb.util.cmdline.api.Application
95
//
96
// ==================================================================
97

98     // ==================================================================
99
//
100
// Public methods for org.objectweb.openccm.command.api.Application
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// Public methods for org.objectweb.openccm.command.api.CommandOnIR3
107
//
108
// ==================================================================
109

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

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

122     /**
123      * Obtains the output file name.
124      *
125      * @result The output file name.
126      */

127     public String JavaDoc
128     getOutputFileName()
129     {
130         return ofile_.getArgument();
131     }
132
133     /**
134      * Indents a file.
135      *
136      * @param filename The file name to indent.
137      *
138      * @return True if ok, else false.
139      */

140     public boolean
141     indent(String JavaDoc inputfile)
142     {
143         org.objectweb.openccm.generator.common.lib.Indentor ind =
144             new org.objectweb.openccm.generator.common.lib.Indentor();
145         try
146         {
147             ind.indent(inputfile);
148         }
149         catch(java.io.IOException JavaDoc e)
150         {
151             getConsole().error("I/O Exception with file " + inputfile);
152             report_exception(e);
153             return false;
154         }
155         return true;
156     }
157
158     // ==================================================================
159
//
160
// Other public methods.
161
//
162
// ==================================================================
163
}
164
Popular Tags