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