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