KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > generator > GenOptions


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop.generator;
19
20 import org.apache.geronimo.interop.rmi.iiop.compiler.StubCompiler;
21
22 import java.util.List JavaDoc;
23 import java.util.LinkedList JavaDoc;
24 import java.util.Iterator JavaDoc;
25
26 public class GenOptions {
27     // -gs genSrcDir
28
// -gc genClassDir
29
// -o overwrite
30
// -v verbose
31
// -s simpleidl
32
// -cp classpath
33
// -g generate
34
// -c compile
35
// -cd compiledebug
36
// -lc loadclass
37

38     private String JavaDoc genSrcDir = "./src";
39     private String JavaDoc genClassDir = "./classes";
40     private boolean overwrite = false;
41     private boolean verbose = false;
42     private boolean simpleidl = false;
43     private String JavaDoc classpath = "";
44     private boolean generate = true;
45     private boolean compile = false;
46     private boolean compileDebug = false;
47     private boolean loadclass = false;
48
49     private List JavaDoc interfaces = new LinkedList JavaDoc();
50
51     public GenOptions( String JavaDoc defaultSrcDir, String JavaDoc args[] )
52         throws GenWarning, GenException {
53         genSrcDir = defaultSrcDir;
54         parseOptions( args );
55     }
56
57     public String JavaDoc getGenSrcDir() {
58         return genSrcDir;
59     }
60
61     public String JavaDoc getGenClassDir() {
62         return genClassDir;
63     }
64
65     public boolean isOverwrite() {
66         return overwrite;
67     }
68
69     public boolean isVerbose() {
70         return verbose;
71     }
72
73     public boolean isSimpleIdl() {
74         return simpleidl;
75     }
76
77     public String JavaDoc getClasspath() {
78         return classpath;
79     }
80
81     public boolean isGenerate() {
82         return generate;
83     }
84
85     public boolean isCompile() {
86         return compile;
87     }
88
89     public boolean isCompileDebug() {
90         return compileDebug;
91     }
92
93     public boolean isLoadclass() {
94         return loadclass;
95     }
96
97     public List JavaDoc getInterfaces() {
98         return interfaces;
99     }
100
101     protected void parseOptions(String JavaDoc args[]) throws GenException, GenWarning {
102         GenWarning genWarning = null;
103
104         for (int i = 0; i < args.length; i++) {
105             if (args[i].equals("-g")) {
106                 generate = true;
107             } else if (args[i].equals("-c")) {
108                 compile = true;
109             } else if (args[i].equals("-cd")) {
110                 compileDebug = true;
111             } else if (args[i].equals("-l")) {
112                 loadclass = true;
113             } else if (args[i].equals("-s")) {
114                 simpleidl = true;
115             } else if (args[i].equals("-gs")) {
116                 if ((i + 1) < args.length) {
117                     genSrcDir = args[++i];
118                 } else {
119                     throw new GenException( "-gs requires an source output diretory." );
120                 }
121             } else if (args[i].equals("-cp")) {
122                 if ((i + 1) < args.length) {
123                     classpath = args[++i];
124                 } else {
125                     throw new GenException( "-cp requires a classpath directory." );
126                 }
127             } else if (args[i].equals("-gc")) {
128                 if ((i + 1) < args.length) {
129                     genClassDir = args[++i];
130                 } else {
131                     throw new GenException( "-gc requires an class output diretory." );
132                 }
133             } else if (args[i].equals("-v")) {
134                 verbose = true;
135             } else if (args[i].equals("-o")) {
136                 overwrite = true;
137             } else if (args[i].startsWith("-")) {
138                 String JavaDoc msg = "Ignoring unrecognized options: '" + args[i] + "'";
139                 if (genWarning != null) {
140                     // just a cheap way of chaining the warnings...
141
genWarning = new GenWarning( msg, genWarning);
142                 } else {
143                     genWarning = new GenWarning( msg );
144                 }
145             } else {
146                 interfaces.add(args[i]);
147             }
148         }
149     }
150 }
151
Popular Tags