KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > csdl > jblanket > modifier > Modifier


1 package csdl.jblanket.modifier;
2
3 import csdl.jblanket.JBlanket;
4 import csdl.jblanket.JBlanketException;
5 import csdl.jblanket.methodset.MethodSet;
6 import csdl.jblanket.methodset.MethodSetManager;
7 import csdl.jblanket.util.JarFactory;
8 import csdl.jblanket.util.MethodCategories;
9
10 import java.io.File JavaDoc;
11 import java.io.FileInputStream JavaDoc;
12 import java.io.FileNotFoundException JavaDoc;
13 import java.io.FileOutputStream JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.text.ParseException JavaDoc;
16 import java.util.ArrayList JavaDoc;
17 import java.util.Date JavaDoc;
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.StringTokenizer JavaDoc;
21
22 import org.apache.tools.ant.DirectoryScanner;
23
24 /**
25  * Provides the command line interface to modify byte code in a Java class or JAR files.
26  * This is the first step in using JBlanket.
27  * <p>
28  * The following tags are <b>required</b> command line arguments for the main methods:
29  * <ul>
30  * <p>
31  * 'classDir' - the directory containing all .class or .jar files to modify<br>
32  * <i>For example</i>: -classDir c:\cvs\jblanket\build\classes
33  * <p>
34  * 'include' - file(s) to be modified located in classDir<br>
35  * <i>For example</i>: -include csdl\jblanket\example\foo\Foo.class
36  * <p>
37  * 'exclude' - file(s) to remain untouched in classDir<br>
38  * <i>For example</i>: -exclude csdl\jblanket\example\foo\TestFoo2.class
39  * <p>
40  * 'testGrammar' - grammar describing the names of the Test classes<br>
41  * <i>For example</i>: -testGrammar Test*.class
42  * </ul>
43  * <p>
44  * The following tags are <b>optional</b> command line arguments:
45  * <ul>
46  * <p>
47  * 'verbose' - describes if instrumentation should execute in verbose mode<br>
48  * <i>For example</i>: -verbose true
49  * <p>
50  * 'excludeOneLineMethods' - describes if one-line methods should be excluded<br>
51  * <i>For example</i>: -excludeOneLineMethods false
52  * <p>
53  * 'excludeConstructors' - describes if constructors should be excluded<br>
54  * <i>For example</i>: -excludeConstructors false
55  * <p>
56  * 'totalFile' - name of the XML file for all methods included in the coverage
57  * measurement<br>
58  * <i>For example</i>: -totalFile totalMethods.xml
59  * <p>
60  * 'untestableFile' - name of the XML file for all abstract or native methods<br>
61  * <i>For example</i>: -untestableFile untestableMethods.xml
62  * <p>
63  * 'excludedFile' - name of the XML file for all methods specifically excluded
64  * from the coverage measurement<br>
65  * <i>For example</i>: -excludedFile excludedMethods.xml
66  * <p>
67  * 'oneLineFile' - name of the XML file for methods containing one line of source
68  * code<br>
69  * <i>For example</i>: -oneLineFile oneLineMethods.xml
70  * <p>
71  * 'constructorFile' - name of the XML file for constructors<br>
72  * <i>For example</i>: -constructorFile constructorMethods.xml
73  * <p>
74  * 'packagePrefix' - name of a package prefix to include in the coverage
75  * measurement<br>
76  * <i>For example</i>: -packagePrefix csdl.jblanket.
77  * </ul>
78  * <p>
79  * Classes are modified inside the 'classDir' directory. Specify multiple files with a
80  * ';'-delimited list. Similarly, exclude multiple files with a ';'-delimited list. 'Test*.class'
81  * and '*Test.class' are the only valid grammars to describe the names of JUnit tests.
82  * <p>
83  * Default values provided for 'totalFile', 'untestableFile', 'excludedFile', 'oneLineFile', and
84  * 'constructorFile' are shown in the examples. However, the 'excludeOneLineMethods' or
85  * 'excludeConstructors' tags must be included to exclude methods with one line of source code or
86  * constructors from the final coverage calculation. Without the tags, percent coverage is equal to
87  * <ul>
88  * <pre>
89  * tested methods / (total methods - untestable methods - excluded methods)
90  * </pre>
91  * </ul>
92  * <p>
93  * With the 'excludeOneLineMethods' tag, percent coverage is equal to
94  * <ul>
95  * <pre>
96  * tested methods / ((total methods - untestable methods - excluded methods) - one-line methods)
97  * </pre>
98  * </ul>
99  * <p>
100  * With the 'excludeConstructors' tag, percent coverage is equal to
101  * <ul>
102  * <pre>
103  * tested methods / ((total methods - untestable methods - excluded methods) - constructors)
104  * </pre>
105  * </ul>
106  * <p>
107  * With both the 'excludeOneLineMethod' and 'excludeConstructors' tags, percent coverage is equal to
108  * <ul>
109  * <pre>
110  * tested methods / (((total methods - untestable methods - excluded methods) - one-line methods)
111  * - constructors)
112  * </pre>
113  * </ul>
114  *
115  * @author Joy M. Agustin
116  * @version $Id: Modifier.java,v 1.2 2005/02/19 05:55:19 timshadel Exp $
117  */

118 public class Modifier extends JBlanket {
119
120   /** Grammar for names of test classes */
121   private String JavaDoc testGrammar = "";
122
123   /** Container for untestable methods */
124   private MethodSet untestableSet;
125   /** Container for methods in excluded classes */
126   private MethodSet excludedSet;
127
128   /** List of package prefixes to include in the coverage measurement */
129   private List JavaDoc packagePrefixes;
130
131   /** Counts the methods found in the system */
132   private MethodCounter counter;
133
134   /** Current date so that all files will have the same date */
135   private Date JavaDoc date;
136
137   /**
138    * Constructs a new Modifier object.
139  * @param verbose describes if JBlanket should execute in verbose mode.
140  * @param testGrammar the grammar describing names of JUnit test classes.
141  * @param excludeOneLineMethods describes if one-line methods should be excluded.
142  * @param excludeConstructors describes if constructors should be excluded.
143  * @param excludeIndividualMethods TODO
144  * @param packagePrefixes the package prefixes to be modified.
145    *
146    * @throws ParseException if <code>testGrammar</code> is invalid.
147    */

148   public Modifier(boolean verbose, String JavaDoc testGrammar, boolean excludeOneLineMethods,
149                    boolean excludeConstructors, boolean excludeIndividualMethods,
150                    List JavaDoc packagePrefixes) throws ParseException JavaDoc {
151     super();
152     this.verbose = verbose;
153     if (isValidTestGrammar(testGrammar)) {
154       this.testGrammar = testGrammar;
155     }
156     
157     // initialize MethodSets
158
MethodSetManager manager = MethodSetManager.getInstance();
159     super.totalSet = manager.getMethodSet(super.categories.getFileName("totalFile"));
160
161     this.excludedSet = manager.getMethodSet(super.categories.getFileName("excludedFile"));
162
163     this.untestableSet = manager.getMethodSet(super.categories.getFileName("untestableFile"));
164
165     // initialize one-line methods MethodSet if needed
166
super.excludeOneLineMethods = excludeOneLineMethods;
167     if (super.excludeOneLineMethods) {
168       super.oneLineSet = manager.getMethodSet(super.categories.getFileName("oneLineFile"));
169     }
170
171     // initialize constructors MethodSet if needed
172
super.excludeConstructors = excludeConstructors;
173     if (super.excludeConstructors) {
174       super.constructorSet = manager.getMethodSet(super.categories.getFileName("constructorFile"));
175     }
176     
177     super.excludeIndividualMethods = excludeIndividualMethods;
178
179     // set all package prefixes
180
if (packagePrefixes.size() > 0) {
181       this.packagePrefixes = packagePrefixes;
182     }
183     else {
184       this.packagePrefixes = null;
185     }
186
187     this.counter = new MethodCounter();
188
189     this.date = new Date JavaDoc();
190   }
191
192   /**
193    * Verifies if <code>testGrammar</code> is valid. The only grammars acceptable are class names
194    * that either begins or ends with 'Test' and end with either '.java' or '.class' file types.
195    * <p>
196    * NOTE: method is package private for testing, else should be private.
197    *
198    * @param testGrammar the grammar defining test class names.
199    * @return true if a part of <code>testGrammar</code>, false otherwise.
200    * @exception ParseException if format of <code>testGrammar</code> is unacceptable.
201    */

202   boolean isValidTestGrammar(String JavaDoc testGrammar) throws ParseException JavaDoc {
203
204     // remove any '.class' or '.java' from testGrammar or last '.'
205
if (testGrammar.endsWith(".java") || testGrammar.endsWith(".class")
206         || testGrammar.lastIndexOf('.') == testGrammar.length() - 1) {
207       testGrammar = testGrammar.substring(0, testGrammar.lastIndexOf('.'));
208     }
209
210     // check if testGrammer ends with any other prefix
211
if (testGrammar.indexOf('.') > -1 &&
212         testGrammar.lastIndexOf('.') < testGrammar.length() - 1) {
213       throw new ParseException JavaDoc("Ill-formed suffix of grammar <" + testGrammar + ">",
214                                testGrammar.lastIndexOf('.'));
215     }
216
217     // check grammar
218
if (testGrammar.endsWith("*") || testGrammar.startsWith("*")) {
219       return true;
220     }
221     else {
222       throw new ParseException JavaDoc("Ill-formed grammar for test class names", 0);
223     }
224   }
225
226   /**
227    * Processes all files to include in the coverage measurement.
228    * <p>
229    * This method performs the following tasks:
230    * <ul>
231    * <li> Records all methods to include in coverage.
232    * <li> Modifies all methods in the byte code of the .class files.
233    * <li> Records methods with only one line of source code when specified by the user.
234    * <li> Records constructors when specified by the user.
235    * </ul>
236    *
237    * @param toDir the output directory for modified classes.
238    * @param includes list of fully qualified .class files to include in coverage.
239    * @throws JBlanketException if cannot save a modified file.
240    */

241   private void processIncludeClasses(String JavaDoc toDir, List JavaDoc includes) throws JBlanketException {
242     // process each file
243
for (Iterator JavaDoc i = includes.iterator(); i.hasNext(); ) {
244
245       // check if file is a .class; if modifying files in .jar, could be .xml, etc.
246
String JavaDoc className = (String JavaDoc) i.next();
247       if (!((className).endsWith(".class"))) {
248         continue;
249       }
250
251       // check if file is supposed to be modified
252
if (this.packagePrefixes != null) {
253
254         boolean modify = false;
255
256         String JavaDoc fullyQualifiedClassName = className.replace(File.separatorChar, '.');
257
258         for (Iterator JavaDoc p = this.packagePrefixes.iterator(); p.hasNext(); ) {
259
260           String JavaDoc packagePrefix = (String JavaDoc) p.next();
261           // if true, modify this class because it begins with a packageprefix
262
if (fullyQualifiedClassName.startsWith(packagePrefix)) {
263
264             modify = true;
265             break;
266           }
267         }
268
269         if (!modify) {
270           // found a class that does not begin with packageprefix, so get next class
271
continue;
272         }
273       }
274
275       // change to full path
276
File JavaDoc classFile = new File JavaDoc(toDir, className);
277       ClassModifier classModifier = new ClassModifier(super.verbose, this.testGrammar,
278                                                       super.excludeOneLineMethods,
279                                                       super.excludeConstructors,
280                                                       super.excludeIndividualMethods,
281                                                       this.counter, classFile);
282       classModifier.modifyMethods();
283     }
284
285     // store all methods found in 'clazz's
286
try {
287
288       this.counter.storeAllMethods();
289
290       // output set of one-line methods
291
if (this.excludeOneLineMethods) {
292         storeMethods(this.oneLineSet, new File JavaDoc(super.categories.getFileName("oneLineFile")));
293       }
294
295       // output set of constructors
296
if (this.excludeConstructors) {
297         storeMethods(this.constructorSet,
298                      new File JavaDoc(super.categories.getFileName("constructorFile")));
299       }
300     }
301     catch (IOException JavaDoc e) {
302       throw new JBlanketException("Unable to store methods", e);
303     }
304   }
305
306   /**
307    * Stores all of the methods in <code>methodSet</code> to <code>fileName</code>.
308    *
309    * @param methodSet the MethodSet with the methods to store in fileName.
310    * @param file the output file.
311    * @throws IOException if cannot load 'totalFile', store to <code>fileName</code>.
312    */

313   protected void storeMethods(MethodSet methodSet, File JavaDoc file) throws IOException JavaDoc {
314
315     // throws FileNotFoundException
316
FileInputStream JavaDoc fistream = new FileInputStream JavaDoc(categories.getFileName("totalFile"));
317     try {
318       this.totalSet.load(fistream);
319     }
320     catch (ParseException JavaDoc e) {
321       // do nothing. Error occurs when file's timestamp cannot be parsed.
322
// Doesn't matter because do not need the date.
323
}
324
325     methodSet.intersection(this.totalSet);
326     
327     // throws FileNotFoundException
328
FileOutputStream JavaDoc fostream = new FileOutputStream JavaDoc(file);
329     methodSet.store(fostream, null, this.date);
330
331     fistream.close();
332     fostream.close();
333   }
334
335   /**
336    * Processes all methods to exclude from the coverage measurement. All method type signatures
337    * are stored in the set of excluded methods.
338    *
339    * @param toDir the output directory for unmodified classes.
340    * @param excludes list of package prefix .class files to exclude from coverage.
341    * @exception JBlanketException if cannot process <code>excludes</code> methods.
342    */

343   private void processExcludeClasses(String JavaDoc toDir, List JavaDoc excludes) throws JBlanketException {
344
345     // process each file
346
for (Iterator JavaDoc i = excludes.iterator(); i.hasNext(); ) {
347
348       // change to full path
349
String JavaDoc className = (String JavaDoc) i.next();
350
351       // check for valid file
352
if (!className.endsWith(".class")) {
353         continue;
354       }
355
356       File JavaDoc classFile = new File JavaDoc(toDir, className);
357       ClassModifier modifier = new ClassModifier(this.verbose, counter, classFile);
358       modifier.excludeMethods();
359     }
360   }
361
362   /**
363    * Processes all JAR files.
364    *
365    * @param dir the directory containing jars to modify.
366    * @param jars list of jar files to modify.
367    * @throws JBlanketException if cannot process <code>jar</code> files.
368    */

369   private void processJarFiles(String JavaDoc dir, List JavaDoc jars) throws JBlanketException {
370
371     // separator between directories
372
final String JavaDoc slash = File.separator;
373
374     // process each file
375
for (Iterator JavaDoc i = jars.iterator(); i.hasNext(); ) {
376
377       // create temporary directory for classes from JAR file
378
String JavaDoc temp = super.jblanketDir + slash + "temp";
379       File JavaDoc tempDir = new File JavaDoc(temp);
380
381       // first, delete directory if it exists
382
if (tempDir.exists()) {
383         deleteDirectory(tempDir);
384       }
385
386       // create a new one
387
tempDir.mkdirs();
388
389       // create new JarFactory to process JAR file
390
JarFactory factory = new JarFactory(temp);
391       File JavaDoc jarFile = new File JavaDoc(dir, (String JavaDoc) i.next());
392       try {
393         factory.unJar(jarFile);
394       }
395       catch (Exception JavaDoc e) {
396         // catches IOException and JarException
397
throw new JBlanketException("Unable to unjar JAR file " + jarFile.getAbsoluteFile(), e);
398       }
399
400       // get all files
401
DirectoryScanner scanner = new DirectoryScanner();
402       scanner.setIncludes(new String JavaDoc[] {"**"});
403       scanner.setExcludes(new String JavaDoc[] {"**" + slash + "META-INF" + slash + "**"});
404       scanner.setBasedir(tempDir);
405       scanner.scan();
406       String JavaDoc files[] = scanner.getIncludedFiles();
407
408       // process included files
409
ArrayList JavaDoc includes = new ArrayList JavaDoc();
410       for (int j = 0; j < files.length; j++) {
411         includes.add(files[j]);
412       }
413       processIncludeClasses(temp, includes);
414
415       // re-pack the JAR file
416
try {
417         factory.jar(jarFile);
418       }
419       catch (Exception JavaDoc e) {
420         // catches IOException and JarException
421
throw new JBlanketException("Unable to jar JAR file " + jarFile.getAbsoluteFile(), e);
422       }
423
424       // delete all files
425
deleteDirectory(tempDir);
426     }
427   }
428
429   /**
430    * Deletes <code>dir</code>ectory.
431    * <p>
432    * Method is package private for testing purposes only, else should be private.
433    *
434    * @param dir the directory to remove.
435    */

436   void deleteDirectory(File JavaDoc dir) {
437
438     // find all files and subdirectories
439
DirectoryScanner scanner = new DirectoryScanner();
440     scanner.setIncludes(new String JavaDoc[] {"**/**"});
441     scanner.setBasedir(dir);
442     scanner.scan();
443
444     // delete files in dir
445
String JavaDoc[] files = scanner.getIncludedFiles();
446     for (int j = 0; j < files.length; j++) {
447       (new File JavaDoc(dir.getAbsolutePath(), files[j])).delete();
448     }
449
450     // delete the dir
451
String JavaDoc[] directories = scanner.getIncludedDirectories();
452     for (int j = directories.length - 1; j > -1 ; j--) {
453       (new File JavaDoc(dir.getAbsolutePath(), directories[j])).delete();
454     }
455   }
456
457   /**
458    * Updates the manager with all types of methods found. The total methods container will be
459    * altered to exclude all untestable methods, i.e., abstract and native methods, and all excluded
460    * methods in user specified excluded classes.
461    *
462    * @throws FileNotFoundException if cannot find 'totalFile'.
463    * @throws IOException if cannot read 'totalFile'.
464    */

465   private void updateTotalMethods() throws FileNotFoundException JavaDoc, IOException JavaDoc {
466
467     // store this untestableSet
468
FileOutputStream JavaDoc fostream = new FileOutputStream JavaDoc(categories.getFileName("untestableFile"));
469     this.untestableSet.store(fostream, null, this.date);
470
471     // store this excludedSet
472
fostream = new FileOutputStream JavaDoc(categories.getFileName("excludedFile"));
473     this.excludedSet.store(fostream, null, this.date);
474
475     // remove other methods from total methods because they cannot be invoked,
476
// so should not be included in the coverage measurement.
477
this.totalSet.difference(this.untestableSet);
478     this.totalSet.difference(this.excludedSet);
479     fostream = new FileOutputStream JavaDoc(categories.getFileName("totalFile"));
480     this.totalSet.store(fostream, null, this.date);
481     fostream.close();
482   }
483
484   /**
485    * Transforms a ';' delimited string to an array of Strings.
486    * <p>
487    * Method is package private for testing purposes only, else should be private.
488    *
489    * @param string the String to transform.
490    * @return ArrayList containing the Strings delimited by ';'.
491    */

492   static List JavaDoc stringToArrayList(String JavaDoc string) {
493
494     List JavaDoc list = new ArrayList JavaDoc();
495
496     if (string != null) {
497
498       StringTokenizer JavaDoc tokens = new StringTokenizer JavaDoc(string, ";");
499       while (tokens.hasMoreElements()) {
500         list.add(tokens.nextToken());
501       }
502     }
503
504     return list;
505   }
506
507   /**
508    * Modifies the files in <code>classDir</code> in the Lists <code>includes</code> and
509    * <code>jars</code> and records the files in <code>excludes</code>.
510    *
511    * @param classDir the directory containing all the subdirectories and files.
512    * @param includes a List of all the class files to modify.
513    * @param excludes a List of all the class files to not modify.
514    * @param jars a List of all the JAR files to modify.
515    * @throws JBlanketException if unable to modify any of the files.
516    */

517   public void modify(String JavaDoc classDir, List JavaDoc includes, List JavaDoc excludes, List JavaDoc jars)
518       throws JBlanketException {
519       
520     processIncludeClasses(classDir, includes);
521     processExcludeClasses(classDir, excludes);
522     processJarFiles(classDir, jars);
523     
524     try {
525       updateTotalMethods();
526     }
527     catch (IOException JavaDoc e) {
528       throw new JBlanketException("Unable to update the total methods set", e);
529     }
530   }
531
532   /**
533    * Provides the command line arguments as an Array.
534    * <p>
535    * See main method below.
536    *
537    * @param args the command line arguments.
538    * @exception IOException if there is error reading unmodified files
539    * @throws Throwable if cannot parse an <code>includes</code> files.
540    */

541   public static void main(String JavaDoc args[]) throws IOException JavaDoc, Throwable JavaDoc {
542     main(java.util.Arrays.asList(args));
543   }
544
545   /**
546    * Processes the command line arguments as a List.
547    * <p>
548    * The command line argument tags are as follows:
549    * <pre>
550    * '-classDir' - directory containing classes to modify
551    * '-include' - names of files found in classDir to modify
552    * '-exclude' - names of files found in classDir to not modify
553    * '-verbose' - describes if should execute in verbose mode
554    * '-testGrammar' - grammar describing the names of the test classes
555    * '-excludeOneLineMethods' - describes if should exclude one-line methods
556    * '-excludeConstructors' - describes if should exclude constructors
557    * '-totalFile' - name of the output XML file for total methods
558    * '-untestableFile' - name of the output XML file for untestable methods
559    * '-excludedFile' - name of the output XML file for excluded methods
560    * '-oneLineFile' - name of the output XML file for one-line methods
561    * '-constructorFile' - name of the output XML file for constructors
562    * '-packagePrefix' - package prefixes to modify if modifying JAR files
563    * </pre>
564    * <p>
565    * After this method executes, all 'include' class or JAR files in -classDir are modified.
566    *
567    * @param args the List of command line arguments.
568    * @throws IOException if there is error reading unmodified files.
569    * @throws JBlanketException if unable to process files.
570    * @throws ParseException if <code>testGrammar</code> is invalid.
571    */

572   public static void main(List JavaDoc args) throws IOException JavaDoc, JBlanketException, ParseException JavaDoc {
573
574     // Directory of where original class files exist
575
String JavaDoc classDir = null;
576
577     // List of files to be modified.
578
String JavaDoc includes = null;
579     // List of JAR files to be modified.
580
String JavaDoc jars = null;
581     // List of files to not modify.
582
String JavaDoc excludes = null;
583
584     // Names of package prefixes to include in the coverage measurement
585
String JavaDoc packagePrefixes = null;
586
587     // Verbose mode
588
boolean verbose = false;
589     // Grammar for names of test classes
590
String JavaDoc testGrammar = "";
591
592     // Exclude one-line methods
593
boolean excludeOneLineMethods = false;
594     // Exclude constructors
595
boolean excludeConstructors = false;
596     boolean excludeIndividualMethods = false;
597
598     MethodCategories categories = MethodCategories.getInstance();
599
600     // index of current command line arguments.
601
int i;
602     // Parses args into corresponsing variables.
603
for (i = 0; i < args.size(); ++i) {
604       String JavaDoc argument = (String JavaDoc) args.get(i);
605       if (argument.equals("-classDir")) {
606         classDir = (String JavaDoc) args.get(++i);
607       }
608       else if (argument.equals("-include")) {
609         String JavaDoc includeFile = (String JavaDoc) args.get(++i);
610         if (includeFile.endsWith(".jar")) {
611           jars = includeFile;
612         }
613         else {
614           includes = includeFile;
615         }
616       }
617       else if (argument.equals("-exclude")) {
618         excludes = (String JavaDoc) args.get(++i);
619       }
620       else if (argument.equals("-verbose")) {
621         verbose = ((Boolean JavaDoc) args.get(++i)).booleanValue();
622       }
623       else if (argument.equals("-testGrammar")) {
624         testGrammar = (String JavaDoc) args.get(++i);
625       }
626       else if (argument.equals("-excludeOneLineMethods")) {
627         excludeOneLineMethods = ((Boolean JavaDoc) args.get(++i)).booleanValue();
628       }
629       else if (argument.equals("-excludeConstructors")) {
630         excludeConstructors = ((Boolean JavaDoc) args.get(++i)).booleanValue();
631       }
632       else if (argument.equals("-excludeIndividualMethods")) {
633         excludeIndividualMethods = ((Boolean JavaDoc) args.get(++i)).booleanValue();
634       }
635       else if (argument.equals("-totalFile")) {
636         categories.addCategory("totalFile", (String JavaDoc) args.get(++i));
637       }
638       else if (argument.equals("-untestableFile")) {
639         categories.addCategory("untestableFile", (String JavaDoc) args.get(++i));
640       }
641       else if (argument.equals("-excludedFile")) {
642         categories.addCategory("excludedFile", (String JavaDoc) args.get(++i));
643       }
644       else if (argument.equals("-oneLineFile")) {
645         categories.addCategory("oneLineFile", (String JavaDoc) args.get(++i));
646       }
647       else if (argument.equals("-constructorFile")) {
648         categories.addCategory("constructorFile", (String JavaDoc) args.get(++i));
649       }
650       else if (argument.equals("-packagePrefix")) {
651         packagePrefixes = (String JavaDoc) args.get(++i);
652       }
653       else {
654         System.out.println("Incorrect usage: " + argument);
655         System.exit(1);
656       }
657     }
658     // Modify all classes specified by include
659
Modifier modifier = new Modifier(verbose, testGrammar, excludeOneLineMethods,
660                                      excludeConstructors, excludeIndividualMethods,
661                                      stringToArrayList(packagePrefixes));
662     modifier.modify(classDir, stringToArrayList(includes), stringToArrayList(excludes),
663                     stringToArrayList(jars));
664   }
665 }
666
Popular Tags