KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > genbase > generator > Config


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Config.java,v 1.2 2004/12/15 09:59:16 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.jonas_lib.genbase.generator;
26
27 import java.io.File JavaDoc;
28 import java.util.Vector JavaDoc;
29
30 import org.objectweb.common.Env;
31
32 import org.objectweb.jonas.server.JClassLoader;
33
34
35 /**
36  * Configuration object storing generation params.
37  */

38 public class Config {
39
40     /** packed mode */
41     public static final int PACKED = 0;
42
43     /** unpacked mode */
44     public static final int UNPACKED = 1;
45
46     /** Java executable name */
47     private String JavaDoc nameJava = "java";
48
49     /** Javac executable name */
50     private String JavaDoc nameJavac = "javac";
51
52     /**
53      * Rmic executable name
54      */

55     private String JavaDoc nameRmic = "rmic";
56
57     /** Javac options */
58     private Vector JavaDoc javacOpts = new Vector JavaDoc();
59
60     /** Bin directory for JDK */
61     private String JavaDoc javaHomeBin = null;
62
63     /** no config needed */
64     private boolean noConfig = false;
65
66     /** verbose mode */
67     private boolean verbose = false;
68
69     /** debug mode */
70     private boolean debug = false;
71
72     /** classpath */
73     private String JavaDoc classpath = ".";
74
75     /** output directory */
76     private File JavaDoc out = new File JavaDoc(".");
77
78     /** keep alrady generated files */
79     private boolean keepGenerated = false;
80
81     /** validating parser ? */
82     private boolean parseWithValidation = true;
83
84     /** configuration error */
85     private boolean error = false;
86
87     /** file input name */
88     private String JavaDoc inputname;
89
90     /** help requested ? */
91     private boolean help = false;
92
93     /** save mode (PACKED/UNPACKED) */
94     private int saveMode = PACKED;
95
96     /**
97      * DTDs use is allowed
98      */

99     private boolean dtdsAllowed = false;
100
101     /**
102      * Creates a new Config. Automatically setup javaHomeBin property. And
103      * create classpath from classloader.
104      */

105     public Config() {
106         // Setup java_home/bin directory
107
setJavaHomeBin(System.getProperty("java.home", ""));
108
109         if (!("".equals(getJavaHomeBin()))) {
110             if (Env.isOsMacOsX()) {
111                 setJavaHomeBin(getJavaHomeBin() + File.separator + "bin" + File.separator);
112             } else {
113                 // JRE Directory !
114
setJavaHomeBin(getJavaHomeBin() + File.separator + ".." + File.separator + "bin" + File.separator);
115             }
116         }
117
118         // classpath
119
JClassLoader ucl = (JClassLoader) (Thread.currentThread().getContextClassLoader());
120         setClasspath(ucl.getClassPath());
121     }
122
123     /**
124      * @param nameJavac Set javac command name to use
125      */

126     public void setNameJavac(String JavaDoc nameJavac) {
127         this.nameJavac = nameJavac;
128     }
129
130     /**
131      * @return Returns the javac command name to use
132      */

133     public String JavaDoc getNameJavac() {
134         return nameJavac;
135     }
136
137     /**
138      * @param javacOpts Set javac Opts
139      */

140     public void setJavacOpts(Vector JavaDoc javacOpts) {
141         this.javacOpts = javacOpts;
142     }
143
144     /**
145      * @return Returns the Javac Opts to use
146      */

147     public Vector JavaDoc getJavacOpts() {
148         return javacOpts;
149     }
150
151     /**
152      * @param javaHomeBin JAVA_HOME/bin directory
153      */

154     public void setJavaHomeBin(String JavaDoc javaHomeBin) {
155         this.javaHomeBin = javaHomeBin;
156     }
157
158     /**
159      * @return Returns the JAVA_HOME/bin directory
160      */

161     public String JavaDoc getJavaHomeBin() {
162         return javaHomeBin;
163     }
164
165     /**
166      * @param noConfig Generate Configuration ?
167      */

168     public void setNoConfig(boolean noConfig) {
169         this.noConfig = noConfig;
170     }
171
172     /**
173      * @return Returns noConfig option
174      */

175     public boolean isNoConfig() {
176         return noConfig;
177     }
178
179     /**
180      * @param verbose Verbose ?
181      */

182     public void setVerbose(boolean verbose) {
183         this.verbose = verbose;
184     }
185
186     /**
187      * @return Returns verbose option
188      */

189     public boolean isVerbose() {
190         return verbose;
191     }
192
193     /**
194      * @param debug Debug ?
195      */

196     public void setDebug(boolean debug) {
197         this.debug = debug;
198     }
199
200     /**
201      * @return Returns debug option
202      */

203     public boolean isDebug() {
204         return debug;
205     }
206
207     /**
208      * @param classpath Classpath to use with java commands
209      */

210     public void setClasspath(String JavaDoc classpath) {
211         this.classpath = classpath;
212     }
213
214     /**
215      * @return Retruns Classpath
216      */

217     public String JavaDoc getClasspath() {
218         return classpath;
219     }
220
221     /**
222      * @param out Output directory
223      */

224     public void setOut(File JavaDoc out) {
225         this.out = out;
226     }
227
228     /**
229      * @return Returns Ouput directory
230      */

231     public File JavaDoc getOut() {
232         return out;
233     }
234
235     /**
236      * @param keepGenerated Kepp Generated files ?
237      */

238     public void setKeepGenerated(boolean keepGenerated) {
239         this.keepGenerated = keepGenerated;
240     }
241
242     /**
243      * @return Returns keepGenerated option
244      */

245     public boolean isKeepGenerated() {
246         return keepGenerated;
247     }
248
249     /**
250      * @param parseWithValidation Parse XML desc with validation ?
251      */

252     public void setParseWithValidation(boolean parseWithValidation) {
253         this.parseWithValidation = parseWithValidation;
254     }
255
256     /**
257      * @return Returns validation
258      */

259     public boolean isParseWithValidation() {
260         return parseWithValidation;
261     }
262
263     /**
264      * @param error Error Mode ?
265      */

266     public void setError(boolean error) {
267         this.error = error;
268     }
269
270     /**
271      * @return Returns true if there is Configuration errors
272      */

273     public boolean isError() {
274         return error;
275     }
276
277     /**
278      * @param inputname File inputname
279      */

280     public void setInputname(String JavaDoc inputname) {
281         this.inputname = inputname;
282     }
283
284     /**
285      * @return Returns file input name
286      */

287     public String JavaDoc getInputname() {
288         return inputname;
289     }
290
291     /**
292      * @param help Help Mode ?
293      */

294     public void setHelp(boolean help) {
295         this.help = help;
296     }
297
298     /**
299      * @return Returns Help option.
300      */

301     public boolean isHelp() {
302         return help;
303     }
304
305     /**
306      * Set Packed Mode for storing.
307      */

308     public void setSavePacked() {
309         this.saveMode = PACKED;
310     }
311
312     /**
313      * Set UnPacked Mode for storing.
314      */

315     public void setSaveUnpacked() {
316         this.saveMode = UNPACKED;
317     }
318
319     /**
320      * @return Returns Save mode
321      */

322     public int getSaveMode() {
323         return saveMode;
324     }
325     /**
326      * @return Returns the nameRmic.
327      */

328     public String JavaDoc getNameRmic() {
329         return nameRmic;
330     }
331     /**
332      * @param nameRmic The nameRmic to set.
333      */

334     public void setNameRmic(String JavaDoc nameRmic) {
335         this.nameRmic = nameRmic;
336     }
337     /**
338      * @return the java command
339      */

340     public String JavaDoc getNameJava() {
341         return nameJava;
342     }
343     /**
344      * @return true if the use of DTDs is allowed.
345      */

346     public boolean isDTDsAllowed() {
347         return dtdsAllowed;
348     }
349
350     /**
351      * Use of DTDs
352      * @param dTDsAllowed The dtdsAllowed to set.
353      */

354     public void setDTDsAllowed(boolean dTDsAllowed) {
355         this.dtdsAllowed = dTDsAllowed;
356     }
357 }
Popular Tags