KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > commands > xmlc > CompileOptsCmdOptions


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: CompileOptsCmdOptions.java,v 1.4 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.commands.xmlc;
25
26 import org.enhydra.xml.io.ErrorReporter;
27 import org.enhydra.xml.xmlc.XMLCException;
28 import org.enhydra.xml.xmlc.commands.options.BooleanOption;
29 import org.enhydra.xml.xmlc.commands.options.FlagOption;
30 import org.enhydra.xml.xmlc.commands.options.Option;
31 import org.enhydra.xml.xmlc.commands.options.OptionSet;
32 import org.enhydra.xml.xmlc.metadata.MetaData;
33
34 /**
35  * Command line options parsing for options that control the compilation
36  * process.
37  */

38 class CompileOptsCmdOptions extends BaseCmdOptions {
39     /**
40      * Class for -verbose option
41      */

42     private class VerboseOption extends FlagOption {
43         /**
44          * Constructor.
45          */

46         public VerboseOption() {
47             super("-verbose",
48                   "- Generate useful output about the compiler process.");
49         }
50
51         /**
52          * Set value.
53          */

54         protected void set(Object JavaDoc clientData) throws XMLCException {
55             ((MetaData)clientData).getCompileOptions().setVerbose(true);
56         }
57     }
58
59     /**
60      * Class for -keep option
61      */

62     private class KeepOption extends FlagOption {
63         /**
64          * Constructor.
65          */

66         public KeepOption() {
67             super("-keep",
68                   "- Keep the generate java source, do not delete it.");
69         }
70
71         /**
72          * Set value.
73          */

74         protected void set(Object JavaDoc clientData) throws XMLCException {
75             ((MetaData)clientData).getCompileOptions().setKeepGeneratedSource(true);
76         }
77     }
78
79     /**
80      * Class for - option
81      */

82     private class NoCompileOption extends FlagOption {
83         /**
84          * Constructor.
85          */

86         public NoCompileOption() {
87             super("-nocompile",
88                   "- If specified, don't compile the generate java file.");
89         }
90
91         /**
92          * Set value.
93          */

94         protected void set(Object JavaDoc clientData) throws XMLCException {
95             ((MetaData)clientData).getCompileOptions().setCompileSource(false);
96         }
97     }
98
99     /**
100      * Class for -info option
101      */

102     private class InfoOption extends FlagOption {
103         /**
104          * Constructor.
105          */

106         public InfoOption() {
107             super("-info",
108                   "- Print useful information about the page object, such as ids and URLs.");
109         }
110
111         /**
112          * Set value.
113          */

114         protected void set(Object JavaDoc clientData) throws XMLCException {
115             ((MetaData)clientData).getCompileOptions().setPrintDocumentInfo(true);
116         }
117     }
118
119     /**
120      * Class for -dump option
121      */

122     private class DumpOption extends FlagOption {
123         /**
124          * Constructor.
125          */

126         public DumpOption() {
127             super("-dump",
128                   "- Dump out the DOM tree for the page.");
129         }
130
131         /**
132          * Set value.
133          */

134         protected void set(Object JavaDoc clientData) throws XMLCException {
135             ((MetaData)clientData).getCompileOptions().setPrintDOM(true);
136         }
137     }
138
139     /**
140      * Class for -parseinfo option
141      */

142     private class ParseInfoOption extends FlagOption {
143         /**
144          * Constructor.
145          */

146         public ParseInfoOption() {
147             super("-parseinfo",
148                   "- Print detailed information about the page parsing.");
149         }
150
151         /**
152          * Set value.
153          */

154         protected void set(Object JavaDoc clientData) throws XMLCException {
155             ((MetaData)clientData).getCompileOptions().setPrintParseInfo(true);
156         }
157     }
158
159     /**
160      * Class for -methods option
161      */

162     private class MethodsOption extends FlagOption {
163         /**
164          * Constructor.
165          */

166         public MethodsOption() {
167             super("-methods",
168                   "- Print the signature of each generated access method.");
169         }
170
171         /**
172          * Set value.
173          */

174         protected void set(Object JavaDoc clientData) throws XMLCException {
175             ((MetaData)clientData).getCompileOptions().setPrintAccessorInfo(true);
176         }
177     }
178
179     /**
180      * Class for -version option
181      */

182     private class VersionOption extends FlagOption {
183         /**
184          * Constructor.
185          */

186         public VersionOption() {
187             super("-version",
188                   "- Print the XMLC version number.");
189         }
190
191         /**
192          * Set value.
193          */

194         protected void set(Object JavaDoc clientData) throws XMLCException {
195             ((MetaData)clientData).getCompileOptions().setPrintVersion(true);
196         }
197     }
198
199     /**
200      * Class for -ssi option
201      */

202     private class SSIOption extends FlagOption {
203         /**
204          * Constructor.
205          */

206         public SSIOption() {
207             super("-ssi",
208                   "- Process server-side include directives");
209         }
210
211         /**
212          * Set value.
213          */

214         protected void set(Object JavaDoc clientData) throws XMLCException {
215             ((MetaData)clientData).getInputDocument().setProcessSSI(true);
216         }
217     }
218
219     // dbr_20020128.1_start
220
/**
221      * Class for -ssibase option
222      */

223     private class SSIBaseOption extends Option {
224         /**
225          * Constructor.
226          */

227         public SSIBaseOption() {
228             super("-ssibase", 1, false,
229                   "basedir - Process absolute given ssi directives relative from the specified dir");
230         }
231
232         /**
233          * Parse an instance of the option.
234          */

235         protected void parse(String JavaDoc[] args,
236                              ErrorReporter errorReporter,
237                              Object JavaDoc clientData) throws XMLCException {
238             //System.out.println("ssibase-arg:" + args[0]);
239
((MetaData)clientData).getInputDocument().setSSIBase(args[0]);
240         }
241     }
242     // dbr_20020128.1_end
243

244     /**
245      * Class for the -docout option.
246      */

247     private class DocOutOption extends Option {
248         /**
249          * Constructor.
250          */

251         public DocOutOption() {
252             super("-docout", 1, false,
253                   "outfile - Write a static document to the outfile instead of generating a class");
254         }
255
256         /**
257          * Parse an instance of the option.
258          */

259         public void parse(String JavaDoc[] args,
260                           ErrorReporter errorReporter,
261                           Object JavaDoc clientData) throws XMLCException {
262             MetaData metaData = (MetaData)clientData;
263             metaData.getCompileOptions().setDocumentOutput(args[0]);
264             metaData.getCompileOptions().setCreateSource(false);
265         }
266     }
267
268     /**
269      * Class for the -sourceout option.
270      */

271     private class SourceOutputOption extends Option {
272         /**
273          * Constructor.
274          */

275         public SourceOutputOption() {
276             super("-sourceout", 1, false,
277                   "sourceout - Root directory for generated source files.");
278         }
279
280         /**
281          * Parse an instance of the option.
282          */

283         protected void parse(String JavaDoc[] args,
284                              ErrorReporter errorReporter,
285                              Object JavaDoc clientData) throws XMLCException {
286             ((MetaData)clientData).getCompileOptions().setSourceOutputRoot(args[0]);
287         }
288     }
289
290     /**
291      * Class for the -warnings option.
292      */

293     private class WarningsOption extends BooleanOption {
294         /**
295          * Constructor.
296          */

297         public WarningsOption() {
298             super("-warnings",
299                   "yes|no|true|false - Enable or disable warnings");
300         }
301
302         /**
303          * Set the value.
304          */

305         protected void set(boolean value,
306                            Object JavaDoc clientData) throws XMLCException {
307             // sets both parse and compile warning flags
308
((MetaData)clientData).getParser().setWarnings(value);
309             ((MetaData)clientData).getCompileOptions().setWarnings(value);
310         }
311     }
312
313     /**
314      * Constructor. Add options to option set.
315      */

316     public CompileOptsCmdOptions(OptionSet optionSet) {
317         super(optionSet);
318         optionSet.addOption(new VersionOption());
319         optionSet.addOption(new KeepOption());
320         optionSet.addOption(new NoCompileOption());
321         optionSet.addOption(new InfoOption());
322         optionSet.addOption(new DumpOption());
323         optionSet.addOption(new VerboseOption());
324         optionSet.addOption(new ParseInfoOption());
325         optionSet.addOption(new MethodsOption());
326         optionSet.addOption(new SSIOption());
327         // dbr_20020128.2_start
328
optionSet.addOption(new SSIBaseOption());
329         // dbr_20020128.2_end
330
optionSet.addOption(new DocOutOption());
331         optionSet.addOption(new SourceOutputOption());
332         optionSet.addOption(new WarningsOption());
333     }
334 }
335
Popular Tags