src/share/jaxws_classes/com/sun/tools/internal/jxc/ap/Options.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.internal.jxc.ap;
27
28 import java.io.File;
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import com.sun.tools.internal.xjc.BadCommandLineException;
33
34 /**
35 * This stores the invocation configuration for
36 * SchemaGenerator
37 *
38 * @author Bhakti Mehta
39 */
40 public class Options {
41
42 public static final String DISABLE_XML_SECURITY = "-disableXmlSecurity";
43
44 // honor CLASSPATH environment variable, but it will be overrided by -cp
45 public String classpath = System.getenv("CLASSPATH");
46
47 public File targetDir = null;
48
49 public File episodeFile = null;
50
51 private boolean disableXmlSecurity = false;
52
53 // encoding is not required for JDK5, 6, but JDK 7 javac is much more strict - see issue 6859289
54 public String encoding = null;
55
56 public final List<String> arguments = new ArrayList<String>();
57
58 public void parseArguments(String[] args) throws BadCommandLineException {
59 for (int i = 0 ; i <args.length; i++) {
60 if (args[i].charAt(0)== '-') {
61 int j = parseArgument(args,i);
62 if(j==0)
63 throw new BadCommandLineException(
64 Messages.UNRECOGNIZED_PARAMETER.format(args[i]));
65 i += j;
66 } else {
67 arguments.add(args[i]);
68 }
69 }
70 }
71
72 private int parseArgument( String[] args, int i ) throws BadCommandLineException {
73 if (args[i].equals("-d")) {
74 if (i == args.length - 1)
75 throw new BadCommandLineException(
76 (Messages.OPERAND_MISSING.format(args[i])));
77 targetDir = new File(args[++i]);
78 if( !targetDir.exists() )
79 throw new BadCommandLineException(
80 Messages.NON_EXISTENT_FILE.format(targetDir));
81 return 1;
82 }
83
84 if (args[i].equals("-episode")) {
85 if (i == args.length - 1)
86 throw new BadCommandLineException(
87 (Messages.OPERAND_MISSING.format(args[i])));
88 episodeFile = new File(args[++i]);
89 return 1;
90 }
91
92 if (args[i].equals(DISABLE_XML_SECURITY)) {
93 if (i == args.length - 1)
94 throw new BadCommandLineException(
95 (Messages.OPERAND_MISSING.format(args[i])));
96 disableXmlSecurity = true;
97 return 1;
98 }
99
100 if (args[i].equals("-encoding")) {
101 if (i == args.length - 1)
102 throw new BadCommandLineException(
103 (Messages.OPERAND_MISSING.format(args[i])));
104 encoding = args[++i];
105 return 1;
106 }
107
108 if (args[i].equals("-cp") || args[i].equals("-classpath")) {
109 if (i == args.length - 1)
110 throw new BadCommandLineException(
111 (Messages.OPERAND_MISSING.format(args[i])));
112 classpath = args[++i];
113
114 return 1;
115 }
116
117 return 0;
118
119 }
120
121 /**
122 * @return the disableXmlSecurity
123 */
124 public boolean isDisableXmlSecurity() {
125 return disableXmlSecurity;
126 }
127
128
129
130 }

mercurial