Refine search
@Override public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException { int ret = 0; if (args[i].startsWith("-Xpof")) { ret = 1; if (args[i].startsWith("-Xpof:typeId=")) { String sTypeId = args[i].substring("-Xpof:typeId=".length()); try { typeId = Long.parseLong(sTypeId); if (typeId < 0) { throw new BadCommandLineException("Initial POF type ID must be a positive integer"); } } catch (NumberFormatException e) { throw new BadCommandLineException("Initial POF type ID must be a positive integer"); } } } return ret; }
private static void _main( String[] args ) throws Exception { try { Driver.run( args, System.out, System.out ); } catch (BadCommandLineException e) { // there was an error in the command line. // print usage and abort. if(e.getMessage()!=null) { System.out.println(e.getMessage()); System.out.println(); } Driver.usage(e.getOptions(),false); } } }
private void _doXJC() throws BuildException { try { options.parseArguments(cmdLine.getArguments()); throw new BuildException(e.getMessage(), e); InputSource[] grammars = options.getGrammars(); model.codeModel.build(new XJCBase.AntProgressCodeWriter(options.createCodeWriter())); } catch (IOException e) { throw new BuildException("unable to write files: " + e.getMessage(), e);
classpaths.add(file.toURL()); } catch (MalformedURLException e) { throw new BadCommandLineException( Messages.format(Messages.NOT_A_VALID_FILENAME,file),e); targetDir = new File(requireArgument("-d",args,++i)); if( !targetDir.exists() ) throw new BadCommandLineException( Messages.format(Messages.NON_EXISTENT_DIR,targetDir)); return 2; target = SpecVersion.parse(token); if(target==null) throw new BadCommandLineException(Messages.format(Messages.ILLEGAL_TARGET_VERSION,token)); return 2; throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYFILE)); throw new BadCommandLineException( Messages.format(Messages.NO_SUCH_FILE,file)); in.close(); } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.FAILED_TO_PARSE,file,e.getMessage()),e); throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXY));
opts.addBindFile(ins); opts.addGrammar(new InputSource("null")); opts.parseArguments(args.toArray(new String[0])); } catch (BadCommandLineException e) { StringBuilder msg = new StringBuilder("XJC reported 'BadCommandLineException' for -xjc argument:"); opts.parseArgument(new String[] {"-" + ToolConstants.CFG_MARK_GENERATED_OPTION}, 0); } catch (BadCommandLineException e) { LOG.log(Level.SEVERE, e.getMessage()); throw new ToolException(e);
throw new BadCommandLineException(); if (args[i].charAt(0) == '-') { int j = parseArgument(args,i); if(j==0) throw new BadCommandLineException( Messages.format(Messages.UNRECOGNIZED_PARAMETER, args[i])); i += (j-1); } else { if(args[i].endsWith(".jar")) scanEpisodeFile(new File(args[i])); else addFile(args[i],grammars,".xsd"); System.setProperty("https.proxyPort", proxyPort); } else if (proxyHost == null) { throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYHOST)); } else { throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYPORT)); throw new BadCommandLineException( Messages.format(Messages.MISSING_GRAMMAR)); throw new BadCommandLineException( Messages.format(Messages.PLUGIN_LOAD_FAILURE,pluginLoadFailure));
/** * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization. */ public void scanEpisodeFile(File jar) throws BadCommandLineException { try { URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()}); Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode"); while (resources.hasMoreElements()) { URL url = resources.nextElement(); addBindFile(new InputSource(url.toExternalForm())); } } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e); } }
/** * Parses a token to a file (or a set of files) * and add them as {@link InputSource} to the specified list. * * @param suffix If the given token is a directory name, we do a recursive search * and find all files that have the given suffix. */ private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException { Object src; try { src = Util.getFileOrURL(name); } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.NOT_A_FILE_NOR_URL, name)); } if (src instanceof URL) { target.add(absolutize(new InputSource(Util.escapeSpace(((URL) src).toExternalForm())))); } else { File fsrc = (File) src; if (fsrc.isDirectory()) { addRecursive(fsrc, suffix, target); } else { target.add(absolutize(fileToInputSource(fsrc))); } } }
i++; if (i == args.length) throw new BadCommandLineException( Messages.format(Messages.MISSING_MODE_OPERAND)); throw new BadCommandLineException( Messages.format(Messages.UNRECOGNIZED_MODE, args[i])); return super.parseArgument(args, i);
final XPathExpression modelGroupExpression = xPath.compile("/xs:schema/xs:group"); final XPathExpression targetNamespaceExpression = xPath.compile("/xs:schema/@targetNamespace"); final Map<String, List<String>> includeMappings = findIncludeMappings(xPath, opts.getGrammars()); final List<InputSource> newGrammars = new ArrayList<>(); for (final InputSource grammarSource : opts.getGrammars()) { final Document grammar = copyInputSource(grammarSource); final String declaredTargetNamespaceUri = targetNamespaceExpression.evaluate(grammar); opts.addGrammar(newGrammar); throw new BadCommandLineException(getMessage("error.plugin-setup", e));
schemaCompiler.getOptions().scanEpisodeFile(new File(args[i])); throw new BadCommandLineException(e.getMessage(), e); schemaCompiler.getOptions().parseArgument( new String[] {"-encoding", encoding}, 0); } catch (com.sun.tools.xjc.BadCommandLineException ex) {
int r = jaxbOptions.parseArgument(subCmd, 0); if(r==0) { } catch (com.sun.tools.xjc.BadCommandLineException e) { throw new BadCommandLineException(e.getMessage(),e);
System.out.println(e.getMessage()); System.out.println(); usage();
return -1; } catch(BadCommandLineException e) { e.initOptions(opt); throw e;
private void _doXJC() throws BuildException { try { options.parseArguments(cmdLine.getArguments()); throw new BuildException(e.getMessage(), e); InputSource[] grammars = options.getGrammars(); model.codeModel.build(new XJCBase.AntProgressCodeWriter(options.createCodeWriter())); } catch (IOException e) { throw new BuildException("unable to write files: " + e.getMessage(), e);
classpaths.add(file.toURL()); } catch (MalformedURLException e) { throw new BadCommandLineException( Messages.format(Messages.NOT_A_VALID_FILENAME,file),e); targetDir = new File(requireArgument("-d",args,++i)); if( !targetDir.exists() ) throw new BadCommandLineException( Messages.format(Messages.NON_EXISTENT_DIR,targetDir)); return 2; target = SpecVersion.parse(token); if(target==null) throw new BadCommandLineException(Messages.format(Messages.ILLEGAL_TARGET_VERSION,token)); return 2; throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYFILE)); throw new BadCommandLineException( Messages.format(Messages.NO_SUCH_FILE,file)); in.close(); } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.FAILED_TO_PARSE,file,e.getMessage()),e); throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXY));
opts.addBindFile(ins); opts.addGrammar(new InputSource("null")); opts.parseArguments(args.toArray(new String[0])); } catch (BadCommandLineException e) { StringBuilder msg = new StringBuilder("XJC reported 'BadCommandLineException' for -xjc argument:"); opts.parseArgument(new String[] {"-" + ToolConstants.CFG_MARK_GENERATED_OPTION}, 0); } catch (BadCommandLineException e) { LOG.log(Level.SEVERE, e.getMessage()); throw new ToolException(e);
throw new BadCommandLineException(); if (args[i].charAt(0) == '-') { int j = parseArgument(args,i); if(j==0) throw new BadCommandLineException( Messages.format(Messages.UNRECOGNIZED_PARAMETER, args[i])); i += (j-1); } else { if(args[i].endsWith(".jar")) scanEpisodeFile(new File(args[i])); else addFile(args[i],grammars,".xsd"); System.setProperty("https.proxyPort", proxyPort); } else if (proxyHost == null) { throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYHOST)); } else { throw new BadCommandLineException( Messages.format(Messages.MISSING_PROXYPORT)); throw new BadCommandLineException( Messages.format(Messages.MISSING_GRAMMAR)); throw new BadCommandLineException( Messages.format(Messages.PLUGIN_LOAD_FAILURE,pluginLoadFailure));
/** * Finds the <tt>META-INF/sun-jaxb.episode</tt> file to add as a binding customization. */ public void scanEpisodeFile(File jar) throws BadCommandLineException { try { URLClassLoader ucl = new URLClassLoader(new URL[]{jar.toURL()}); Enumeration<URL> resources = ucl.findResources("META-INF/sun-jaxb.episode"); while (resources.hasMoreElements()) { URL url = resources.nextElement(); addBindFile(new InputSource(url.toExternalForm())); } } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.FAILED_TO_LOAD,jar,e.getMessage()), e); } }
/** * Parses a token to a file (or a set of files) * and add them as {@link InputSource} to the specified list. * * @param suffix * If the given token is a directory name, we do a recusive search * and find all files that have the given suffix. */ private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException { Object src; try { src = Util.getFileOrURL(name); } catch (IOException e) { throw new BadCommandLineException( Messages.format(Messages.NOT_A_FILE_NOR_URL,name)); } if(src instanceof URL) { target.add(absolutize(new InputSource(Util.escapeSpace(((URL)src).toExternalForm())))); } else { File fsrc = (File)src; if(fsrc.isDirectory()) { addRecursive(fsrc,suffix,target); } else { target.add(absolutize(fileToInputSource(fsrc))); } } }