Package jargs.gnu

Examples of jargs.gnu.CmdLineParser$OptionException


        if (args.length<2) {
            System.out.println("No arguments specified!\n");
            throw new InvalidParameterException("No arguments specified!");
        }

        CmdLineParser parser = new CmdLineParser();
        CmdLineParser.Option host = parser.addStringOption('h', PARAM_HOST);
        CmdLineParser.Option port = parser.addIntegerOption('p', PARAM_PORT);
        CmdLineParser.Option command = parser.addStringOption('c', PARAM_COMMAND);

        String pCmd = "undefined";
        try {
            parser.parse(args);
            String pHost = (String)parser.getOptionValue(host, DEFAULT_HOST);
            int pPort = (Integer)parser.getOptionValue(port, DEFAULT_PORT);
            pCmd = (String)parser.getOptionValue(command);       
            if (pCmd==null) {
                System.out.println("Unknown Command: "+ArrayUtils.toString(args));
                System.out.println("Exit now");
                throw new IllegalArgumentException("no ValidCommand specified!");
            }
           
            ValidCommands parsedCommand = ValidCommands.valueOf(pCmd.toUpperCase());
            String[] otherArgs = parser.getRemainingArgs();
           
            if (parsedCommand.getNrOfParams() < otherArgs.length) {
              String err = "Invalid parameter count, expected: "+parsedCommand.getNrOfParams()+", provided: "+otherArgs.length;
              System.out.println(err);
              throw new InvalidParameterException(err);
View Full Code Here


      testOutputDirectory = new Path((String) cmdLine.getValue(testOutputDirOpt));
    
      charset = Charset.forName((String) cmdLine.getValue(charsetOpt));

      if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
      }

      if (cmdLine.hasOption(testSplitSizeOpt)) {
        setTestSplitSize(Integer.parseInt((String) cmdLine.getValue(testSplitSizeOpt)));
      }
View Full Code Here

        if (wString.equalsIgnoreCase("tf")) {
          processIdf = false;
        } else if (wString.equalsIgnoreCase("tfidf")) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
     
View Full Code Here

            if (wString.equalsIgnoreCase("tf")) {
              weight = new TF();
            } else if (wString.equalsIgnoreCase("tfidf")) {
              weight = new TFIDF();
            } else {
              throw new OptionException(weightOpt);
            }
          } else {
            weight = new TFIDF();
          }
          String field = cmdLine.getValue(fieldOpt).toString();
View Full Code Here

          if (dictionaryType.equals("text")) {
            dictionary = VectorHelper.loadTermDictionary(new File(cmdLine.getValue(dictOpt).toString()));
          } else if (dictionaryType.equals("sequencefile")) {
            dictionary = VectorHelper.loadTermDictionary(conf, fs, cmdLine.getValue(dictOpt).toString());
          } else {
            throw new OptionException(dictTypeOpt);
          }
        }
        boolean useJSON = cmdLine.hasOption(centroidJSonOpt);
       
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

    public void process(final WriteableCommandLine commandLine, final ListIterator arguments)
        throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, arg);
      }

      ArrayList properties = new ArrayList();
      String next = "";
      while (arguments.hasNext()) {
        next = (String) arguments.next();
        if (!next.startsWith("-")) {

          if (keyValue && (next.indexOf("=") == -1)) {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, "argument: '"
                + next + "' is not of the form x=y");
          }
          properties.add(next);
        } else {
          arguments.previous();
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

      testOutputDirectory = new Path((String) cmdLine.getValue(testOutputDirOpt));
    
      charset = Charset.forName((String) cmdLine.getValue(charsetOpt));

      if (cmdLine.hasOption(testSplitSizeOpt) && cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option, not BOTH");
      } else if (!cmdLine.hasOption(testSplitSizeOpt) && !cmdLine.hasOption(testSplitPctOpt)) {
        throw new OptionException(testSplitSizeOpt, "must have either split size or split percentage option");
      }

      if (cmdLine.hasOption(testSplitSizeOpt)) {
        setTestSplitSize(Integer.parseInt((String) cmdLine.getValue(testSplitSizeOpt)));
      }
View Full Code Here

    public void process(final WriteableCommandLine commandLine,
                        final ListIterator arguments) throws OptionException {
      final String arg = (String) arguments.next();

      if (!canProcess(commandLine, arg)) {
        throw new OptionException(this,
                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
      }
     
      ArrayList properties = new ArrayList();
      String next = "";
View Full Code Here

        if ("tf".equalsIgnoreCase(wString)) {
          processIdf = false;
        } else if ("tfidf".equalsIgnoreCase(wString)) {
          processIdf = true;
        } else {
          throw new OptionException(weightOpt);
        }
      } else {
        processIdf = true;
      }
     
View Full Code Here

TOP

Related Classes of jargs.gnu.CmdLineParser$OptionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.