Package jargs.gnu

Examples of jargs.gnu.CmdLineParser$OptionException


                    arguments.add(argument.substring(burstLength));
                }

                arguments.previous();
            } else {
                throw new OptionException(this, ResourceConstants.CANNOT_BURST, argument);
            }
        } else {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, argument);
        }
    }
View Full Code Here


    }

    public void validate(WriteableCommandLine commandLine)
        throws OptionException {
        if (isRequired() && !commandLine.hasOption(this)) {
            throw new OptionException(this, ResourceConstants.OPTION_MISSING_REQUIRED,
                                      getPreferredName());
        }

        super.validate(commandLine);
    }
View Full Code Here

            commandLine.addOption(this);

            // normalise the argument list
            arguments.set(preferredName);
        } else {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN, arg);
        }
    }
View Full Code Here

    }

    public void validate(WriteableCommandLine commandLine)
        throws OptionException {
        if (isRequired() && !commandLine.hasOption(this)) {
            throw new OptionException(this, ResourceConstants.OPTION_MISSING_REQUIRED,
                                      getPreferredName());
        }

        super.validate(commandLine);
    }
View Full Code Here

            }
        }

        // too many options
        if (unexpected != null) {
            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN,
                                      unexpected.getPreferredName());
        }

        // too few option
        if (present < minimum) {
            throw new OptionException(this, ResourceConstants.MISSING_OPTION);
        }

        // validate each anonymous argument
        for (final Iterator i = anonymous.iterator(); i.hasNext();) {
            final Option option = (Option) i.next();
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

      useMapRed = getOption(DefaultOptionCreator.METHOD_OPTION).equalsIgnoreCase(DefaultOptionCreator.MAPREDUCE_METHOD);

      if (useMapRed) {
        if (!hasOption("randomSelectionPct")) {
          throw new OptionException(getCLIOption("randomSelectionPct"),
                  "must set randomSelectionPct when mapRed option is used");
        }
        if (!hasOption("mapRedOutputDir")) {
          throw new OptionException(getCLIOption("mapRedOutputDir"),
                                    "mapRedOutputDir must be set when mapRed option is used");
        }
        mapRedOutputDirectory = new Path(getOption("mapRedOutputDir"));
        if (hasOption("keepPct")) {
          keepPct = Integer.parseInt(getOption("keepPct"));
        }
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(getConf(), mapRedOutputDirectory);
        }
      } else {
        if (!hasOption("trainingOutput")
                || !hasOption("testOutput")) {
          throw new OptionException(getCLIOption("trainingOutput"),
                  "trainingOutput and testOutput must be set if mapRed option is not used");
        }
        if (!hasOption("testSplitSize")
                && !hasOption("testSplitPct")
                && !hasOption("randomSelectionPct")
                && !hasOption("randomSelectionSize")) {
          throw new OptionException(getCLIOption("testSplitSize"),
                  "must set one of test split size/percentage or randomSelectionSize/percentage");
        }

        trainingOutputDirectory = new Path(getOption("trainingOutput"));
        testOutputDirectory = new Path(getOption("testOutput"));
        FileSystem fs = trainingOutputDirectory.getFileSystem(getConf());
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(fs.getConf(), trainingOutputDirectory);
          HadoopUtil.delete(fs.getConf(), testOutputDirectory);
        }
        fs.mkdirs(trainingOutputDirectory);
        fs.mkdirs(testOutputDirectory);
      }

      if (hasOption("charset")) {
        charset = Charset.forName(getOption("charset"));
      }

      if (hasOption("testSplitSize") && hasOption("testSplitPct")) {
        throw new OptionException(getCLIOption("testSplitPct"), "must have either split size or split percentage "
            + "option, not BOTH");
      }

      if (hasOption("testSplitSize")) {
        setTestSplitSize(Integer.parseInt(getOption("testSplitSize")));
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

      useMapRed = getOption(DefaultOptionCreator.METHOD_OPTION).equalsIgnoreCase(DefaultOptionCreator.MAPREDUCE_METHOD);

      if (useMapRed) {
        if (!hasOption("randomSelectionPct")) {
          throw new OptionException(getCLIOption("randomSelectionPct"),
                  "must set randomSelectionPct when mapRed option is used");
        }
        if (!hasOption("mapRedOutputDir")) {
          throw new OptionException(getCLIOption("mapRedOutputDir"),
                                    "mapRedOutputDir must be set when mapRed option is used");
        }
        mapRedOutputDirectory = new Path(getOption("mapRedOutputDir"));
        if (hasOption("keepPct")) {
          keepPct = Integer.parseInt(getOption("keepPct"));
        }
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(getConf(), mapRedOutputDirectory);
        }
      } else {
        if (!hasOption("trainingOutput")
                || !hasOption("testOutput")) {
          throw new OptionException(getCLIOption("trainingOutput"),
                  "trainingOutput and testOutput must be set if mapRed option is not used");
        }
        if (!hasOption("testSplitSize")
                && !hasOption("testSplitPct")
                && !hasOption("randomSelectionPct")
                && !hasOption("randomSelectionSize")) {
          throw new OptionException(getCLIOption("testSplitSize"),
                  "must set one of test split size/percentage or randomSelectionSize/percentage");
        }

        trainingOutputDirectory = new Path(getOption("trainingOutput"));
        testOutputDirectory = new Path(getOption("testOutput"));
        FileSystem fs = trainingOutputDirectory.getFileSystem(getConf());
        if (hasOption(DefaultOptionCreator.OVERWRITE_OPTION)) {
          HadoopUtil.delete(fs.getConf(), trainingOutputDirectory);
          HadoopUtil.delete(fs.getConf(), testOutputDirectory);
        }
        fs.mkdirs(trainingOutputDirectory);
        fs.mkdirs(testOutputDirectory);
      }

      if (hasOption("charset")) {
        charset = Charset.forName(getOption("charset"));
      }

      if (hasOption("testSplitSize") && hasOption("testSplitPct")) {
        throw new OptionException(getCLIOption("testSplitPct"), "must have either split size or split percentage option, not BOTH");
      }

      if (hasOption("testSplitSize")) {
        setTestSplitSize(Integer.parseInt(getOption("testSplitSize")));
      }
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.