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 JdoMetaOptions
29 extends ClassArgOptions
30 {
31 /***
32 * The jdo path option.
33 */
34 public final StringOption jdoPath
35 = createStringOption("jdopath", "j",
36 "<path> : path for lookup of jdo files");
37
38 /***
39 * The jdo properties option.
40 */
41 public final StringOption jdoPropertiesFile
42 = createStringOption("properties", null,
43 "<file> : use property file for JDO metadata");
44
45 /***
46 * Creates an instance.
47 */
48 public JdoMetaOptions(PrintWriter out,
49 PrintWriter err)
50 {
51 super(out, err);
52 }
53
54
55
56 /***
57 * Print a usage message to System.err.
58 */
59 public void printUsageHeader()
60 {
61 printlnErr("Usage: <options>.. <arguments>..");
62 printlnErr(indent
63 + "JDO metadata options:");
64 printlnErr(indent
65 + " --properties <file> [-j <path>] use property file for JDO metadata");
66 printlnErr(indent
67 + " -j <path> lookup .jdo files in the specified path");
68 printlnErr(indent
69 + "Source option and arguments:");
70 printlnErr(indent
71 + " -s <path> <classname>..");
72 printlnErr(indent
73 + " <classfile>..");
74 printlnErr(indent
75 + " <archivefile>..");
76 }
77
78 /***
79 * Check options and arguments.
80 */
81 public int check()
82 {
83 int res;
84 if ((res = super.check()) != OK) {
85 return res;
86 }
87
88
89 if (jdoPropertiesFile.value == null &&
90 jdoPath.value == null && archiveFileNames.isEmpty()) {
91 printUsageError("No JDO metadata option: specify either properties file or jdo-path for lookup of jdo files");
92 return USAGE_ERROR;
93 }
94
95 return OK;
96 }
97
98
99
100 /***
101 * Tests the class.
102 */
103 static public void main(String[] args)
104 {
105 final PrintWriter out = new PrintWriter(System.out, true);
106 out.println("--> JdoMetaOptions.main()");
107 final JdoMetaOptions options = new JdoMetaOptions(out, out);
108 out.println(" options.process() ...");
109 int res = options.process(args);
110 out.println(" return value: " + res);
111 out.println("<-- JdoMetaOptions.main()");
112 }
113 }