File: 02-args4j-compatibility.patch

package info (click to toggle)
jaxb 2.3.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,388 kB
  • sloc: java: 108,759; xml: 16,672; sh: 654; jsp: 384; makefile: 17
file content (141 lines) | stat: -rw-r--r-- 5,427 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Description: Fixes the compatibility with the version of args4j in Debian
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/Main.java
+++ b/jaxb-ri/txw/compiler/src/main/java/com/sun/tools/txw2/Main.java
@@ -43,10 +43,10 @@
 import com.sun.codemodel.writer.FileCodeWriter;
 import com.sun.codemodel.writer.SingleStreamCodeWriter;
 import com.sun.tools.txw2.model.NodeSet;
+import org.kohsuke.args4j.Argument;
 import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
-import org.kohsuke.args4j.opts.BooleanOption;
-import org.kohsuke.args4j.opts.StringOption;
+import org.kohsuke.args4j.Option;
 import org.kohsuke.rngom.parse.IllegalSchemaException;
 import org.kohsuke.rngom.parse.Parseable;
 import org.kohsuke.rngom.parse.compact.CompactParseable;
@@ -78,21 +78,34 @@
     }
 
     public static class Options {
-        public StringOption output = new StringOption("-o");
-        public StringOption pkg = new StringOption("-p");
-        public BooleanOption compact = new BooleanOption("-c");
-        public BooleanOption xml = new BooleanOption("-x");
-        public BooleanOption xsd = new BooleanOption("-xsd");
-        public BooleanOption chain = new BooleanOption("-h");
+        @Option(name="-o", metaVar="<dir>", usage="Specify the directory to place generated source files")
+        public String output;
+
+        @Option(name="-p", metaVar="<pkg>", usage="Specify the Java package to put the generated classes into")
+        public String pkg;
+
+        @Option(name="-c", usage="The input schema is written in the RELAX NG compact syntax")
+        public boolean compact;
+
+        @Option(name="-x", usage="The input schema is written in the RELAX NG XML syntax")
+        public boolean xml;
+
+        @Option(name="-xsd", usage="The input schema is written in the XML Schema")
+        public boolean xsd;
+
+        @Option(name="-h", usage="Generate code that allows method invocation chaining")
+        public boolean chain;
+
+        @Argument
+        private java.util.List<String> arguments = new java.util.ArrayList<String>();
     }
 
     public static int run(String[] args) {
         Options opts = new Options();
-        CmdLineParser parser = new CmdLineParser();
-        parser.addOptionClass(opts);
+        CmdLineParser parser = new CmdLineParser(opts);
 
         try {
-            parser.parse(args);
+            parser.parseArgument(args);
         } catch (CmdLineException e) {
             System.out.println(e.getMessage());
             printUsage();
@@ -102,9 +115,9 @@
         TxwOptions topts = new TxwOptions();
         topts.errorListener = new ConsoleErrorReporter(System.out);
 
-        if(opts.output.value!=null) {
+        if(opts.output!=null) {
             try {
-                topts.codeWriter = new FileCodeWriter(new File(opts.output.value));
+                topts.codeWriter = new FileCodeWriter(new File(opts.output));
             } catch( IOException e ) {
                 System.out.println(e.getMessage());
                 printUsage();
@@ -114,12 +127,12 @@
             topts.codeWriter = new SingleStreamCodeWriter(System.out);
         }
 
-        if(opts.chain.isOn()) {
+        if(opts.chain) {
             topts.chainMethod = true;
         }
 
-        if(opts.pkg.value!=null) {
-            topts._package = topts.codeModel._package(opts.pkg.value);
+        if(opts.pkg!=null) {
+            topts._package = topts.codeModel._package(opts.pkg);
         } else {
             topts._package = topts.codeModel.rootPackage();
         }
@@ -146,21 +159,21 @@
      * out of the specified schema file.
      */
     private static SchemaBuilder makeSourceSchema(CmdLineParser parser, Options opts, ErrorHandler eh) throws MalformedURLException {
-        File f = new File((String)parser.getArguments().get(0));
+        File f = new File(opts.arguments.get(0));
         final InputSource in = new InputSource(f.toURL().toExternalForm());
 
-        if(opts.xsd.isOff() && opts.xml.isOff() && opts.compact.isOff()) {
+        if(!opts.xsd && !opts.xml && !opts.compact) {
             // auto detect
             if(in.getSystemId().endsWith(".rnc"))
-                opts.compact.value=true;
+                opts.compact=true;
             else
             if(in.getSystemId().endsWith(".rng"))
-                opts.xml.value=true;
+                opts.xml=true;
             else
-                opts.xsd.value=true;
+                opts.xsd=true;
         }
 
-        if(opts.xsd.isOn())
+        if(opts.xsd)
             return new XmlSchemaLoader(in);
 
         final Parseable parseable = makeRELAXNGSource(opts, in, eh, f);
@@ -169,10 +182,10 @@
     }
 
     private static Parseable makeRELAXNGSource(Options opts, final InputSource in, ErrorHandler eh, File f) {
-        if(opts.compact.isOn())
+        if(opts.compact)
             return new CompactParseable(in,eh);
 
-        if(opts.xml.isOn())
+        if(opts.xml)
             return new SAXParseable(in,eh);
 
         // otherwise sniff from the file extension
--- a/jaxb-ri/txw/compiler/pom.xml
+++ b/jaxb-ri/txw/compiler/pom.xml
@@ -93,6 +93,7 @@
         <dependency>
             <groupId>args4j</groupId>
             <artifactId>args4j</artifactId>
+            <version>debian</version>
         </dependency>
     </dependencies>