01: package com.ibm.sigtest;
02:
03: import java.io.File;
04:
05: /**
06: * This class compares a project file to either the classes currently available
07: * on the classpath, or another project file.
08: * @author Matthew J. Duftler (duftler@us.ibm.com)
09: */
10: public class TestSignatures {
11:
12: private static void printUsage() {
13: System.err.println("Usage:\n\n" + " java "
14: + TestSignatures.class.getName() + " [args]\n\n"
15: + " args:\n\n"
16: + " -projectFile1 name of file containing "
17: + "signatures\n"
18: + " [-projectFile2 name of file to compare "
19: + "projectFile1 to]\n"
20: + " If this argument is not "
21: + "specified, projectFile1 is\n"
22: + " compared to the classes "
23: + "currently available on the\n"
24: + " classpath.");
25: System.exit(1);
26: }
27:
28: public static void main(String[] argv) throws Exception {
29: if (argv.length % 2 != 0) {
30: printUsage();
31: }
32:
33: File projectFile1 = null;
34: File projectFile2 = null;
35:
36: for (int i = 0; i < argv.length; i += 2) {
37: String option = argv[i];
38: String value = argv[i + 1];
39:
40: if (option.equals("-projectFile1")) {
41: projectFile1 = new File(value);
42: } else if (option.equals("-projectFile2")) {
43: projectFile2 = new File(value);
44: } else {
45: printUsage();
46: }
47: }
48:
49: if (projectFile1 == null) {
50: printUsage();
51: }
52:
53: String result = null;
54:
55: if (projectFile2 == null) {
56: result = ProjectDesc.compareProjectFile(projectFile1);
57: } else {
58: ProjectDesc pd1 = ProjectDesc.readProjectFile("Project 1",
59: projectFile1);
60: ProjectDesc pd2 = ProjectDesc.readProjectFile("Project 2",
61: projectFile2);
62:
63: result = pd1.compare(pd2);
64: }
65:
66: System.out.println(result != null ? result
67: : "They match perfectly.");
68: }
69: }
|