KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > util > Ajc


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22 package org.aspectj.util;
23
24 //import java.io.*;
25
//import java.util.*;
26

27 // XXX wes remove this class as unused, inverse dependency
28
//public class Ajc {
29
//
30
// public Ajc() {
31
// check();
32
// reload();
33
// }
34
//
35
// private String cmdLine = "";
36
// private PrintStream out = System.out;
37
// private PrintStream err = System.err;
38
// private InputStream in = System.in;
39
// private BufferedReader input = null;
40
// private final String prompt = "> ";
41
// private Map arguments = new HashMap();
42
// private Collection files = new HashSet();
43
// private void removeFile(String file) {
44
// files.remove(file);
45
// }
46
// private final Integer EMPTY = new Integer(0);
47
// private void setArgument(String arg, String val) {
48
// arguments.put(arg, val);
49
// }
50
// private void setArgument(String arg) {
51
// arguments.put(arg, EMPTY);
52
// }
53
// private void unsetArgument(String arg) {
54
// arguments.remove(arg);
55
// }
56
//
57
// public void realMain(String[] args) {
58
// parse(args);
59
// open();
60
// String cmd;
61
// while (!quit(cmd = input())) {
62
// process(cmd);
63
// }
64
// close();
65
// save();
66
// }
67
//
68
// private void check() {
69
// try {
70
// Class.forName("org.aspectj.tools.ajc.Main");
71
// } catch (ClassNotFoundException e) {
72
// err.println("Cannot find main class");
73
// exit();
74
// }
75
// }
76
//
77
// private String usage() {
78
// return "Look at the source!";
79
// }
80
//
81
// private void process(String cmd) {
82
// cmd = (cmd != null ? cmd : "").trim();
83
// if (thread != null && "".equals(cmd)) {
84
// out(prompt());
85
// }
86
// if (cmd.startsWith("ajc") || cmd.startsWith("$")) {
87
// int iwhite = cmd.indexOf(" ");
88
// if (iwhite != -1) {
89
// process(cmd.substring(iwhite));
90
// }
91
// String cmdLine = "ajc";
92
// String[] args = args();
93
// for (int i = 0; i < args.length; i++) {
94
// cmdLine += " " + args[i];
95
// }
96
// outln(newline + "\t" + cmdLine + newline);
97
// while(compile(args)) {}
98
// Thread.yield();
99
// } else if (cmd.startsWith("help")) {
100
// outln(usage());
101
// } else if ("files".equals(cmd)) {
102
// outln(filesString());
103
// } else if ("args".equals(cmd)) {
104
// outln(argumentsString());
105
// } else if (cmd.startsWith("clear")) {
106
// boolean clearArgs = false;
107
// boolean clearFiles = false;
108
// if (cmd.length() > "clear".length()) {
109
// String rest = cmd.substring("clear".length()+1).trim();
110
// System.out.println("rest=" + rest);
111
// if ("files".equals(rest)) clearFiles = true;
112
// if ("args".equals(rest)) clearArgs = true;
113
// } else {
114
// clearArgs = true;
115
// clearFiles = true;
116
// }
117
// if (clearArgs) arguments = new HashMap();
118
// if (clearFiles) files = new HashSet();
119
// } else if ("save".equals(cmd)) {
120
// save();
121
// } else if ("load".equals(cmd)) {
122
// reload();
123
// } else {
124
// update(cmd.trim());
125
// }
126
//
127
// }
128
//
129
// private void update(String cmd) {
130
// files.addAll(removeArguments(cmd));
131
// }
132
//
133
// private void update(List args) {
134
// files.addAll(removeArguments(args));
135
// }
136
//
137
// private final static String quote = "\"";
138
// private List removeArguments(String cmd) {
139
// return removeArguments(new ArgumentScanner().scanToList(cmd));
140
// }
141
// private List removeArguments(List args) {
142
// List rest = new Vector();
143
// Iterator iter = args.iterator();
144
// String arg;
145
// String foundArg = null;
146
// boolean remove = false;
147
// while (iter.hasNext()) {
148
// arg = (""+iter.next()).trim();
149
// if (arg.startsWith("!")) {
150
// remove = true;
151
// if (arg.length() == 1 && iter.hasNext()) {
152
// arg = iter.next() + "";
153
// } else {
154
// arg = arg.substring(1);
155
// }
156
// } else {
157
// remove = false;
158
// }
159
// if (arg.startsWith("-")) {
160
// foundArg = arg;
161
// if (!remove) {
162
// setArgument(foundArg);
163
// } else {
164
// unsetArgument(foundArg);
165
// }
166
// } else {
167
// if (foundArg == null) {
168
// if (remove) {
169
// removeFile(arg);
170
// } else {
171
// rest.add(arg);
172
// }
173
// } else {
174
// setArgument(foundArg, arg);
175
// }
176
// foundArg = null;
177
// }
178
// }
179
// return rest;
180
// }
181
//
182
//
183
//
184
// private boolean quit(String cmd) {
185
// return "quit".equals(cmd) || "exit".equals(cmd);
186
// }
187
//
188
// private String input() {
189
// try {
190
// return input_();
191
// } catch (Throwable t) {
192
// handle(t);
193
// }
194
// return "quit";
195
// }
196
// private void open() {
197
// try {
198
// input = new BufferedReader(new InputStreamReader(in));
199
// } catch (Throwable t) {
200
// handle(t, true);
201
// }
202
// }
203
// private void close() {
204
// try {
205
// if (input != null) input.close();
206
// } catch (Throwable t) {
207
// handle(t, true);
208
// }
209
// }
210
// private String input_() throws IOException {
211
// out(prompt());
212
// return input.readLine();
213
// }
214
//
215
// private String[] args() {
216
// String[] args = new String[argsList().size() + filesList().size()];
217
// int i = 0;
218
// Iterator iter;
219
// iter = argsList().iterator();
220
// while (iter.hasNext()) args[i++] = iter.next() + "";
221
// iter = filesList().iterator();
222
// while (iter.hasNext()) args[i++] = iter.next() + "";
223
// return args;
224
// }
225
//
226
// private List filesList() {
227
// List list = new Vector();
228
// Iterator iter = files.iterator();
229
// while (iter.hasNext()) {
230
// String next = (""+iter.next()).trim();
231
// if (!"".equals(next)) list.add(next);
232
// }
233
// return list;
234
// }
235
//
236
// private List argsList() {
237
// List args = new Vector();
238
// Iterator iter = arguments.keySet().iterator();
239
// while (iter.hasNext()) {
240
// Object arg = iter.next();
241
// args.add(arg);
242
// Object val = arguments.get(arg);
243
// if (val != null && !val.equals(EMPTY)) {
244
// args.add(val);
245
// }
246
// }
247
// return args;
248
// }
249
//
250
// private final static int maxArgsLength = 50;
251
// private final static int maxFilesLength = 50;
252
// private final static int maxPromptLength = 100;
253
// private String reduce(String str, int i) {
254
// if (str.length() > i) return "...";
255
// return str;
256
// }
257
// private String arguments() {
258
// return reduce(reduce(argumentsString(), maxArgsLength) + ":" +
259
// reduce(filesString(), maxFilesLength),
260
// maxPromptLength).trim();
261
// }
262
//
263
// private String argumentsString() {
264
// String argsStr = "";
265
// Iterator iter = arguments.keySet().iterator();
266
// while (iter.hasNext()) {
267
// Object arg = iter.next();
268
// Object val = arguments.get(arg);
269
// argsStr += arg;
270
// if (!val.equals(EMPTY)) {
271
// argsStr += " " + val;
272
// }
273
// if (iter.hasNext()) {
274
// argsStr += ",";
275
// }
276
// }
277
// return argsStr;
278
// }
279
//
280
// private String filesString() {
281
// String filesStr = "";
282
// Iterator iter = files.iterator();
283
// while (iter.hasNext()) {
284
// filesStr += iter.next() + (iter.hasNext() ? " " : "");
285
// }
286
// return filesStr;
287
// }
288
//
289
// private String prompt() {
290
// return arguments() + prompt;
291
// }
292
//
293
// private boolean time_opt = true;
294
// private void parse(String[] args) {
295
// List list = new Vector();
296
// for (int i = 0; i < args.length; i++) {
297
// list.add(args[i]);
298
// }
299
// update(list);
300
// }
301
//
302
// private Thread thread;
303
// private boolean compile(final String[] args) {
304
// if (thread != null) {
305
// outln("A compile is already running: " + cmdLine);
306
// return false;
307
// }
308
// try {
309
// thread = new Thread(new Runnable() {
310
// public void run() {
311
// long start = -1;
312
// try {
313
// start = System.currentTimeMillis();
314
// Class mainClass = Class.forName("org.aspectj.tools.ajc.Main");
315
// mainClass.getMethod("compile", new Class[]{String[].class}).invoke
316
// (mainClass.newInstance(),new Object[]{args});
317
// } catch (Throwable t) {
318
// handle(t);
319
// } finally {
320
// thread = null;
321
// long stop = System.currentTimeMillis();
322
// if (time_opt) outln("total time: " + (((double)stop-start)/1000) + "ms.");
323
// out(prompt());
324
// }
325
// }
326
// });
327
// thread.start();
328
// Thread.yield();
329
// } catch (Throwable t) {
330
// handle(t);
331
// }
332
// return false;
333
// }
334
//
335
// private final static String newline = System.getProperty("line.separator");
336
//
337
// private void handle(Throwable t, boolean exit) {
338
// errln("Internal error:");
339
// t.printStackTrace(err);
340
// if (exit) exit();
341
// }
342
//
343
// private void handle(Throwable t) {
344
// handle(t, false);
345
// }
346
//
347
// private void exit() {
348
// save();
349
// System.exit(-1);
350
// }
351
//
352
// private void out(Object msg) {
353
// out.print(msg);
354
// }
355
//
356
// private void outln(Object msg) {
357
// out.println(msg);
358
// }
359
//
360
// private void err(Object msg) {
361
// err.print(msg);
362
// }
363
//
364
// private void errln(Object msg) {
365
// err.println(msg);
366
// }
367
//
368
// private boolean verbose = true;
369
// private void log(Object msg) {
370
// if (verbose) outln("[" + msg + "]");
371
// }
372
//
373
// public static void main(String[] args) {
374
// new Ajc().realMain(args);
375
// }
376
//
377
// private static final String saveFileName = ".ajcoptions";
378
// private void save() {
379
// try {
380
// File saveFile = saveFile();
381
// if (saveFile == null) return;
382
// FileOutputStream ostream = new FileOutputStream(saveFile);
383
// ObjectOutputStream p = new ObjectOutputStream(ostream);
384
// p.writeObject(arguments);
385
// p.writeObject(files);
386
// p.flush();
387
// ostream.close();
388
// } catch (Throwable t) {
389
// handle(t);
390
// }
391
// }
392
//
393
// private File saveFile() {
394
// String home = System.getProperty("user.home");
395
// File homeDir = new File(home);
396
// File saveFile = null;
397
// if (homeDir != null && homeDir.exists() && homeDir.isDirectory()) {
398
// saveFile = new File(homeDir, saveFileName);
399
// }
400
// if (saveFile == null) {
401
// saveFile = new File(saveFileName);
402
// }
403
// return saveFile;
404
// }
405
//
406
// private void reload() {
407
// try {
408
// File saveFile = saveFile();
409
// if (saveFile == null || !saveFile.exists()) return;
410
// FileInputStream istream = new FileInputStream(saveFile);
411
// ObjectInputStream p = new ObjectInputStream(istream);
412
// arguments = (Map) p.readObject();
413
// files = (Collection) p.readObject();
414
// istream.close();
415
// } catch (Throwable t) {
416
// handle(t);
417
// }
418
// }
419
//}
420
Popular Tags