1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.enhancer;
19
20 import java.io.PrintWriter;
21
22
23 /***
24 * Set of options used by the JDO enhancer and its test programs.
25 *
26 * @author Martin Zaun
27 */
28 public class EnhancerOptions
29 extends JdoMetaOptions
30 {
31 /***
32 * The quiet option.
33 */
34 public final FlagOption quiet
35 = createFlagOption("quiet", "q",
36 " : suppress warnings");
37 /***
38 * The force write option.
39 */
40 public final FlagOption forceWrite
41 = createFlagOption("forcewrite", "f",
42 " : overwrite output files");
43
44 /***
45 * The no write option.
46 */
47 public final FlagOption noWrite
48 = createFlagOption("nowrite", "n",
49 " : never write output files");
50
51 /***
52 * The destination directory option.
53 */
54 public final StringOption destDir
55 = createStringOption("destdir", "d",
56 "<path> : directory for any output files");
57
58 /***
59 * The dump class option.
60 */
61 public final FlagOption dumpClass
62 = createFlagOption("dumpclass", null,
63 " : dump out disassembled byte-code");
64
65 /***
66 * The suppress augmentation option.
67 */
68 public final FlagOption noAugment
69 = createFlagOption("noaugment", null,
70 " : do not enhance for persistence-capability");
71
72 /***
73 * The suppress annotation option.
74 */
75 public final FlagOption noAnnotate
76 = createFlagOption("noannotate", null,
77 " : do not enhance for persistence-awareness");
78
79 /***
80 * Creates an instance.
81 */
82 public EnhancerOptions(PrintWriter out,
83 PrintWriter err)
84 {
85 super(out, err);
86 }
87
88
89
90 /***
91 * Print a usage message to System.err.
92 */
93 public void printUsageHeader()
94 {
95 printlnErr("Usage: <options>.. <arguments>..");
96 printlnErr(indent
97 + "-j <path> -s <path> -d <dir> <classname>..");
98 printlnErr(indent
99 + "-j <path> -d <dir> <classfile>..");
100
101
102
103
104
105
106
107 }
108
109 /***
110 * Check options and arguments.
111 */
112 public int check()
113 {
114 int res;
115 if ((res = super.check()) != OK) {
116 return res;
117 }
118
119
120 if (destDir.value == null && !classNames.isEmpty()) {
121 printUsageError("No destination directory specified for enhanced classes");
122 return USAGE_ERROR;
123 }
124
125
126
127 if (destDir.value == null && !classFileNames.isEmpty()) {
128 printUsageError("No destination directory specified for enhanced classes");
129 return USAGE_ERROR;
130 }
131
132 return OK;
133 }
134
135
136
137 /***
138 * Tests the class.
139 */
140 static public void main(String[] args)
141 {
142 final PrintWriter out = new PrintWriter(System.out, true);
143 out.println("--> EnhancerOptions.main()");
144 final EnhancerOptions options = new EnhancerOptions(out, out);
145 out.println(" options.process() ...");
146 int res = options.process(args);
147 out.println(" return value: " + res);
148 out.println("<-- EnhancerOptions.main()");
149 }
150 }