1 19 20 package org.netbeans.modules.websvc.registry.jaxrpc; 21 22 import java.io.*; 23 import java.util.*; 24 25 import org.openide.util.NbBundle; 26 27 public class WSCompileArguments { 28 protected String additionalClasspath; 29 private List features = new ArrayList(); 31 32 private String classpath; 33 34 35 private String outputDirectory; 36 37 38 private String gen; 39 40 41 private boolean keep = true; 42 43 44 private String nonclassOutputDirectory; 45 46 47 private String sourceOutputDirectory; 48 49 50 private boolean define; 51 52 53 private boolean importGen; 54 55 56 private boolean verbose; 57 58 private String mappingFile; 59 60 61 private Configuration configuration; 62 63 private List extraArguments = new LinkedList(); 64 65 public final static int TYPE_NEED_NO_PARAM = 0; 67 public final static int TYPE_NEED_PARAM = 1; 69 public final static int TYPE_INTERNAL = 0x010; 71 public final static int TYPE_NON_COMPILE = 0x100; 73 74 78 public WSCompileArguments() { 79 } 80 81 85 public WSCompileArguments(String additionalClasspath) { 86 this.additionalClasspath = additionalClasspath; 87 } 88 89 public void addArgument(String arg) { 90 addArgument(arg, null); 91 } 92 93 98 public void addArgument(String arg, String param) { 99 arg = arg.intern(); 100 if (arg == "-gen") 101 setGen(""); 102 else if (arg.startsWith("-gen:")) 103 setGen(arg.substring(5, arg.length())); 104 else if (arg == "-define") 105 setDefine(true); 106 else if (arg == "-import") 107 setImportGen(true); 108 else if (arg == "-classpath") 109 setClasspath(param); 110 else if (arg == "-d") 111 setOutputDirectory(param); 112 else if (arg == "-nd") 113 setNonclassOutputDirectory(param); 114 else if (arg == "-s") 115 setSourceOutputDirectory(param); 116 else if (arg == "-keep") 117 setKeep(true); 118 else if (arg == "-verbose") 119 setVerbose(true); 120 else if (arg == "-mapping") 121 setMapping(param); 122 else { 123 if (param == null) 124 extraArguments.add(arg); 125 else 126 extraArguments.add(arg+" "+param); 127 } 128 } 129 130 public void addFeature(String feature) { 131 if ("documentliteral".equals(feature)) { 133 features.remove("rpcliteral"); 134 } else if ("rpcliteral".equals(feature)) { 135 features.remove("documentliteral"); 136 } else if ("unwrap".equals(feature)) { 137 features.remove("donotunwrap"); 138 } else if ("donotunwrap".equals(feature)) { 139 features.remove("unwrap"); 140 } 141 features.add(feature); 142 } 143 144 public void removeFeature(String feature) { 145 features.remove(feature); 146 } 147 148 public boolean hasFeature(String feature) { 149 return features.contains(feature); 150 } 151 152 public void setSearchSchemaForSubtypes() { 153 features.add("searchschema"); 154 } 155 156 public void setUseDataHandlerOnly() { 157 features.add("datahandleronly"); 158 } 159 160 public String [] toArgs() { 161 List args = new LinkedList(); 162 163 if (gen != null) { 164 if (define || importGen) 165 throw new IllegalStateException (NbBundle.getMessage(WSCompileArguments.class, "MSG_MutuallyExclusiveGenDefineImport")); 166 if (gen.equals("")) 167 args.add("-gen"); 168 else { 169 args.add("-gen:"+gen); 170 } 171 } 172 if (define) { 173 if (gen != null || importGen) 174 throw new IllegalStateException (NbBundle.getMessage(WSCompileArguments.class, "MSG_MutuallyExclusiveGenDefineImport")); 175 args.add("-define"); 176 } 177 if (importGen) { 178 if (gen != null || define) 179 throw new IllegalStateException (NbBundle.getMessage(WSCompileArguments.class, "MSG_MutuallyExclusiveGenDefineImport")); 180 args.add("-import"); 181 } 182 if (classpath != null) { 183 args.add("-classpath"); 184 args.add(classpath); 185 } 186 if (mappingFile != null) { 187 args.add("-mapping"); 188 args.add(mappingFile); 189 } 190 if (outputDirectory != null) { 191 args.add("-d"); 192 args.add(outputDirectory); 193 } 194 if (nonclassOutputDirectory != null) { 195 args.add("-nd"); 196 args.add(nonclassOutputDirectory); 197 } 198 if (sourceOutputDirectory != null) { 199 args.add("-s"); 200 args.add(sourceOutputDirectory); 201 } 202 if (keep) 203 args.add("-keep"); 204 if (verbose) 205 args.add("-verbose"); 206 if (features.size() > 0) { 207 String featureArg = "-f:"; 208 boolean first = true; 209 for (Iterator it = features.iterator(); it.hasNext(); ) { 210 if (first) 211 first = false; 212 else 213 featureArg += ","; 214 featureArg += (String ) it.next(); 215 } 216 args.add(featureArg); 217 } 218 219 if (configuration != null) { 220 try { 221 File cf = File.createTempFile("jaxrpcconfigfile", ".xml"); 222 cf.deleteOnExit(); 223 OutputStream out = new FileOutputStream(cf); 224 configuration.write(out); 225 out.close(); 226 args.add(cf.getAbsolutePath()); 227 } catch (IOException e) { 228 throw new RuntimeException (e); 229 } 230 } 231 232 String [] result = new String [args.size()]; 233 return (String []) args.toArray(result); 234 } 235 236 240 public String getClasspath() { 241 return this.classpath; 242 } 243 244 248 public void setClasspath(String classpath) { 249 if (additionalClasspath == null) 250 this.classpath = classpath; 251 else 252 this.classpath = classpath + File.pathSeparator + additionalClasspath; 253 } 254 255 public String getMapping() { 256 return mappingFile; 257 } 258 259 public void setMapping(String m) { 260 mappingFile = m; 261 } 262 263 267 public String getOutputDirectory() { 268 return this.outputDirectory; 269 } 270 271 275 public void setOutputDirectory(String outputDirectory) { 276 this.outputDirectory = outputDirectory; 277 } 278 279 public void setOutputDirectory(File outputDirectory) { 280 this.outputDirectory = outputDirectory.getAbsolutePath(); 281 } 282 283 287 public String getGen() { 288 return this.gen; 289 } 290 291 295 public void setGen(String gen) { 296 this.gen = gen; 297 } 298 299 303 public boolean isKeep() { 304 return this.keep; 305 } 306 307 311 public void setKeep(boolean keep) { 312 this.keep = keep; 313 } 314 315 319 public String getNonclassOutputDirectory() { 320 return this.nonclassOutputDirectory; 321 } 322 323 327 public void setNonclassOutputDirectory(String nonclassOutputDirectory) { 328 this.nonclassOutputDirectory = nonclassOutputDirectory; 329 } 330 331 335 public String getSourceOutputDirectory() { 336 return this.sourceOutputDirectory; 337 } 338 339 343 public void setSourceOutputDirectory(String sourceOutputDirectory) { 344 this.sourceOutputDirectory = sourceOutputDirectory; 345 } 346 347 351 public boolean isDefine() { 352 return this.define; 353 } 354 355 359 public void setDefine(boolean define) { 360 this.define = define; 361 } 362 363 367 public boolean isImportGen() { 368 return this.importGen; 369 } 370 371 375 public void setImportGen(boolean importGen) { 376 this.importGen = importGen; 377 } 378 379 383 public boolean isVerbose() { 384 return this.verbose; 385 } 386 387 391 public void setVerbose(boolean verbose) { 392 this.verbose = verbose; 393 } 394 395 public String toString() { 396 String [] args = toArgs(); 397 String result = ""; 398 for (int i = 0; i < args.length; ++i) { 399 if (i > 0) 400 result += " "; 401 result += args[i]; 402 } 403 return result; 404 } 405 406 410 public Configuration getConfiguration() { 411 return this.configuration; 412 } 413 414 418 public void setConfiguration(Configuration configuration) { 419 this.configuration = configuration; 420 } 421 422 426 public void prepConfigurationForWSDL(java.net.URL location, java.lang.String packageName) { 427 if (configuration == null) 428 configuration = new Configuration(); 429 if (configuration.getWsdl() == null) 430 configuration.setWsdl(new WsdlType(location, packageName)); 431 else { 432 configuration.getWsdl().setLocation(location); 433 configuration.getWsdl().setPackageName(packageName); 434 } 435 } 436 } 437 | Popular Tags |