Example usage for org.apache.commons.cli Option getValue

List of usage examples for org.apache.commons.cli Option getValue

Introduction

In this page you can find the example usage for org.apache.commons.cli Option getValue.

Prototype

public String getValue() 

Source Link

Document

Returns the specified value of this Option or null if there is no value.

Usage

From source file:ro.cs.products.Executor.java

private static void printCommandLine(CommandLine cmd) {
    Logger.getRootLogger().debug("Executing with the following arguments:");
    for (Option option : cmd.getOptions()) {
        if (option.hasArgs()) {
            Logger.getRootLogger().debug(option.getOpt() + "=" + String.join(" ", option.getValues()));
        } else if (option.hasArg()) {
            Logger.getRootLogger().debug(option.getOpt() + "=" + option.getValue());
        } else {/* ww w .  j  ava  2s  . co  m*/
            Logger.getRootLogger().debug(option.getOpt());
        }
    }
}

From source file:texnlp.apps.CatCombine.java

public static void main(String[] args) {

    CommandLineParser optparse = new PosixParser();

    Options options = new Options();
    options.addOption("s", "tagset", true, "the file containing the categories");
    options.addOption("o", "output", true, "the file containing the categories");

    try {//w ww .j  av  a2s  .c  om
        CommandLine cline = optparse.parse(options, args);

        String tagsetFile = "";
        String outputType = "boolean";
        for (Option option : cline.getOptions()) {
            String value = option.getValue();
            switch (option.getOpt().charAt(0)) {
            case 's':
                tagsetFile = value;
                break;
            case 'o':
                outputType = value;
                break;
            }
        }

        TObjectIntHashMap<String> states = new TObjectIntHashMap<String>();
        String[] stateNames;
        int numStates = 0;

        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(tagsetFile)));

        int stateID = 0;
        String line = null;
        while ((line = br.readLine()) != null)
            states.put(line.trim(), stateID++);

        states.trimToSize();

        numStates = stateID;
        stateNames = new String[numStates];
        for (TObjectIntIterator<String> it = states.iterator(); it.hasNext();) {
            it.advance();
            stateNames[it.value()] = it.key();
        }

        int numTags = numStates;
        CategoryParser catp = new CategoryParser();
        Cat[] cats = new Cat[numTags];

        for (int i = 0; i < numTags; i++) {
            String catString = Cat.changeNonCats(stateNames[i]);
            // String catString = stateNames[i];
            Cat c = catp.parse(catString);
            cats[i] = c;
        }

        TransitionPrior tprior = new TransitionPrior(stateNames, states);

        for (int i = 0; i < numTags; i++) {
            for (int j = 0; j < numTags; j++) {
                String outputVal = "0";
                if (outputType.equals("weighted"))
                    outputVal = "1";

                if (Rules.canCombine(cats[i], cats[j])) {
                    outputVal = "1";
                    if (outputType.equals("weighted"))
                        outputVal = "10";
                }
                if (outputType.equals("prior"))
                    outputVal = Double.toString(tprior.tt[i][j]);

                System.out.println(outputVal + " " + stateNames[i] + " " + stateNames[j]);
            }

            String outputForEOS = "0";
            if (outputType.equals("weighted"))
                outputForEOS = "1";

            if (cats[i].notSeekingDir(Slash.R)) {
                outputForEOS = "1";
                if (outputType.equals("weighted"))
                    outputForEOS = "10";
            }

            if (outputType.equals("prior"))
                outputForEOS = Double.toString(tprior.tFinal[i]);

            System.out.println(outputForEOS + " " + stateNames[i] + " EOS");

        }

        for (int j = 0; j < numTags; j++) {
            String outputForBOS = "0";
            if (outputType.equals("weighted"))
                outputForBOS = "1";

            if (cats[j].notSeekingDir(Slash.L)) {
                outputForBOS = "1";
                if (outputType.equals("weighted"))
                    outputForBOS = "10";
            }

            if (outputType.equals("prior"))
                outputForBOS = Double.toString(tprior.tInitial[j]);

            System.out.println(outputForBOS + " BOS " + stateNames[j]);
        }

    } catch (ParseException exp) {
        System.out.println("Unexpected exception parsing command line options:" + exp.getMessage());
    } catch (IOException exp) {
        System.out.println("IOException:" + exp.getMessage());
        System.exit(0);
    }

}

From source file:texnlp.util.TaggerOptions.java

public TaggerOptions(CommandLine cline) throws IOException {

    boolean outputDirSet = false;
    for (Option option : cline.getOptions()) {
        String value = option.getValue();
        switch (option.getOpt().charAt(0)) {
        case 'a':
            setNumMachines(Integer.parseInt(value));
            break;
        case 'b':
            setBeta(Double.parseDouble(value));
            break;
        case 'c':
            setCutoffTD(Double.parseDouble(value));
            break;
        case 'd':
            setDevFile(value);//  w w w  .j av a  2  s.co  m
            break;
        case 'e':
            setEvalFile(value);
            break;
        case 'f':
            setFormat(value);
            break;
        case 'g':
            setTagdictTraining(true);
            break;
        case 'i':
            setNumIterations(Integer.parseInt(value));
            break;
        case 'j':
            setDirichletTransition(true);
            break;
        case 'k':
            setDirichletEmission(true);
            break;
        case 'l':
            setMachineFile(value);
            break;
        case 'm':
            setModelType(value);
            break;
        case 'n':
            setMultitag(true);
            break;
        case 'o':
            setOutputDir(value);
            outputDirSet = true;
            break;
        case 'p':
            setPriorAmount(Double.parseDouble(value));
            break;
        case 'q':
            setLambda(Double.parseDouble(value));
            break;
        case 'r':
            setRawFile(value);
            break;
        case 's':
            setTagsetFile(value);
            break;
        case 't':
            setTaggedFile(value);
            break;
        case 'u':
            setUnconstrainedByTagdict(true);
            break;
        case 'v':
            setValidTagsForUnknownsMinCount(Integer.parseInt(value));
            break;
        case 'w':
            setContextGen(value);
            break;
        case 'z':
            setTolerance(Double.parseDouble(value));
            break;
        }
    }

    if (!outputDirSet)
        createOutputDir();
}

From source file:tikka.bhmm.apps.CommandLineOptions.java

/**
 *
 * @param cline/*from   www . ja va 2s .c  o m*/
 * @throws IOException
 */
public CommandLineOptions(CommandLine cline) throws IOException {

    String opt = null;

    for (Option option : cline.getOptions()) {
        String value = option.getValue();
        switch (option.getOpt().charAt(0)) {
        case 'a':
            alpha = Double.parseDouble(value);
            break;
        case 'b':
            beta = Double.parseDouble(value);
            break;
        case 'c':
            if (value.equals("conll2k")) {
                dataFormat = DataFormatEnum.DataFormat.CONLL2K;
            } else if (value.equals("hashslash")) {
                dataFormat = DataFormatEnum.DataFormat.HASHSLASH;
            } else if (value.equals("pipesep")) {
                dataFormat = DataFormatEnum.DataFormat.PIPESEP;
            } else if (value.equals("raw")) {
                dataFormat = DataFormatEnum.DataFormat.RAW;
            } else {
                System.err.println("\"" + value + "\" is an unknown data format option.");
                System.exit(1);
            }
            break;
        case 'd':
            if (value.endsWith("" + File.separator)) {
                trainDataDir = value.substring(0, value.length() - 1);
            } else {
                trainDataDir = value;
            }
            break;
        case 'e':
            experimentModel = value;
            break;
        case 'f':
            if (value.endsWith("" + File.separator)) {
                testDataDir = value.substring(0, value.length() - 1);
            } else {
                testDataDir = value;
            }
            break;
        case 'g':
            gamma = Double.parseDouble(value);
            break;
        case 'i':
            opt = option.getOpt();
            if (opt.equals("itr")) {
                numIterations = Integer.parseInt(value);
            } else if (opt.equals("ite")) {
                testSetBurninIterations = Integer.parseInt(value);
            }
            break;
        case 'j':
            if (value.endsWith("" + File.separator)) {
                annotatedTestTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTestTextOutDir = value;
            }
            break;
        case 'k':
            opt = option.getOpt();
            if (opt.equals("ks")) {
                samples = Integer.parseInt(value);
            } else if (opt.equals("kl")) {
                lag = Integer.parseInt(value);
            }
            break;
        case 'l':
            modelInputPath = value;
            break;
        case 'm':
            modelOutputPath = value;
            break;
        case 'n':
            if (value.endsWith("" + File.separator)) {
                annotatedTrainTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTrainTextOutDir = value;
            }
            break;
        case 'o':
            opt = option.getOpt();
            if (opt.equals("ot")) {
                tabularOutputFilename = value;
                tabulatedOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(tabularOutputFilename)));
            } else if (opt.equals("oste")) {
                testEvaluationOutputFilename = value;
                testEvaluationOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(testEvaluationOutputFilename)));
            } else if (opt.equals("ostr")) {
                trainDataSampleScoreOutputFilename = value;
                trainDataSampleScoreOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(trainDataSampleScoreOutputFilename)));
            } else if (opt.equals("oe")) {
                evaluationOutputFilename = value;
                evaluationOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(evaluationOutputFilename)));
            }
            break;
        case 'p':
            opt = option.getOpt();
            if (opt.equals("pi")) {
                initialTemperature = Double.parseDouble(value);
            } else if (opt.equals("pd")) {
                temperatureDecrement = Double.parseDouble(value);
            } else if (opt.equals("pt")) {
                targetTemperature = Double.parseDouble(value);
            }
            break;
        case 'q':
            delta = Double.parseDouble(value);
            break;
        case 'r':
            if (value.equals("0")) {
                randomSeed = -1;
            } else {
                randomSeed = Integer.valueOf(value);
            }
            break;
        case 's':
            opt = option.getOpt();
            if (opt.equals("sc")) {
                contentstates = Integer.parseInt(value);
            } else if (opt.equals("sf")) {
                functionstates = Integer.parseInt(value);
            }
            break;
        case 't':
            topics = Integer.parseInt(value);
            break;
        case 'u':
            opt = option.getOpt();
            if (opt.equals("ut")) {
                if (value.equals("b")) {
                    tagSet = TagSetEnum.TagSet.BROWN;
                } else if (value.equals("p")) {
                    tagSet = TagSetEnum.TagSet.PTB;
                } else if (value.equals("t")) {
                    tagSet = TagSetEnum.TagSet.TIGER;
                } else if (value.equals("u")) {
                    tagSet = TagSetEnum.TagSet.USP;
                } else if (value.equals("f")) {
                    tagSet = TagSetEnum.TagSet.FLORESTA;
                } else if (value.equals("n")) {
                    tagSet = TagSetEnum.TagSet.NONE;
                }
            } else if (opt.equals("ur")) {
                int val = Integer.parseInt(value);
                if (val == 0) {
                    reductionLevel = TagSetEnum.ReductionLevel.FULL;
                } else {
                    reductionLevel = TagSetEnum.ReductionLevel.REDUCED;
                }
            }
            break;
        case 'w':
            outputPerClass = Integer.parseInt(value);
            break;
        case 'x':
            opt = option.getOpt();
            if (opt.equals("xd")) {
                posDictPath = value;
            } else if (opt.equals("xt")) {
                useTrigram = true;
            } else if (opt.equals("xthread")) {
                numThread = Integer.parseInt(value);
            } else if (opt.equals("xc")) {
                chunks = Integer.parseInt(value);
            } else if (opt.equals("xp")) {
                phash = Double.parseDouble(value);
            }
            break;
        }
    }
}

From source file:tikka.hhl.apps.CommandLineOptions.java

/**
 * //from   w  w  w.j  a v a 2s.c  o m
 * @param cline
 * @throws IOException
 */
public CommandLineOptions(CommandLine cline) throws IOException {

    String opt = null;

    for (Option option : cline.getOptions()) {
        String value = option.getValue();
        switch (option.getOpt().charAt(0)) {
        case 'a':
            alpha = Double.parseDouble(value);
            break;
        case 'b':
            beta = Double.parseDouble(value);
            break;
        case 'c':
            if (value.equals("conll2k")) {
                dataFormat = DataFormatEnum.DataFormat.CONLL2K;
            } else if (value.equals("hashslash")) {
                dataFormat = DataFormatEnum.DataFormat.HASHSLASH;
            } else if (value.equals("pipesep")) {
                dataFormat = DataFormatEnum.DataFormat.PIPESEP;
            } else if (value.equals("raw")) {
                dataFormat = DataFormatEnum.DataFormat.RAW;
            } else {
                System.err.println("\"" + value + "\" is an unknown data format option.");
                System.exit(1);
            }
            break;
        case 'd':
            if (value.endsWith("" + File.separator)) {
                trainDataDir = value.substring(0, value.length() - 1);
            } else {
                trainDataDir = value;
            }
            break;
        case 'e':
            experimentModel = value;
            break;
        case 'f':
            if (value.endsWith("" + File.separator)) {
                testDataDir = value.substring(0, value.length() - 1);
            } else {
                testDataDir = value;
            }
            break;
        case 'g':
            gamma = Double.parseDouble(value);
            break;
        case 'i':
            opt = option.getOpt();
            if (opt.equals("itr")) {
                numIterations = Integer.parseInt(value);
            } else if (opt.equals("ite")) {
                testSetBurninIterations = Integer.parseInt(value);
            }
            break;
        case 'j':
            if (value.endsWith("" + File.separator)) {
                annotatedTestTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTestTextOutDir = value;
            }
            break;
        case 'k':
            opt = option.getOpt();
            if (opt.equals("ks")) {
                samples = Integer.parseInt(value);
            } else if (opt.equals("kl")) {
                lag = Integer.parseInt(value);
            }
            break;
        case 'l':
            modelInputPath = value;
            break;
        case 'm':
            modelOutputPath = value;
            break;
        case 'n':
            if (value.endsWith("" + File.separator)) {
                annotatedTrainTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTrainTextOutDir = value;
            }
            break;
        case 'o':
            opt = option.getOpt();
            if (opt.equals("ot")) {
                tabularOutputFilename = value;
                tabulatedOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(tabularOutputFilename)));
            } else if (opt.equals("oste")) {
                testDataSampleScoreOutputFilename = value;
                testDataSampleScoreOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(testDataSampleScoreOutputFilename)));
            } else if (opt.equals("ostr")) {
                trainDataSampleScoreOutputFilename = value;
                trainDataSampleScoreOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(trainDataSampleScoreOutputFilename)));
            }
            break;
        case 'p':
            opt = option.getOpt();
            if (opt.equals("pi")) {
                initialTemperature = Double.parseDouble(value);
            } else if (opt.equals("pr")) {
                targetTemperature = Double.parseDouble(value);
            } else if (opt.equals("pt")) {
                temperatureDecrement = Double.parseDouble(value);
            }
            break;
        case 'q':
            topicSubStates = Integer.valueOf(value);
            break;
        case 'r':
            randomSeed = Integer.valueOf(value);
            break;
        case 's':
            states = Integer.parseInt(value);
            break;
        case 't':
            topics = Integer.parseInt(value);
            break;
        case 'w':
            outputPerClass = Integer.parseInt(value);
            break;
        case 'x':
            opt = option.getOpt();
            if (opt.equals("xmustembase")) {
                muStemBase = Double.parseDouble(value);
            } else if (opt.equals("xmustem")) {
                muStem = Double.parseDouble(value);
            } else if (opt.equals("xbetastembase")) {
                betaStemBase = Double.parseDouble(value);
            } else if (opt.equals("xbetastem")) {
                betaStem = Double.parseDouble(value);
            } else if (opt.equals("xmuaffixbase")) {
                muAffixBase = Double.parseDouble(value);
            } else if (opt.equals("xmuaffix")) {
                muAffix = Double.parseDouble(value);
            } else if (opt.equals("xpsi")) {
                psi = Double.parseDouble(value);
            } else if (opt.equals("xxi")) {
                xi = Double.parseDouble(value);
            } else if (opt.equals("xstemboundaryprob")) {
                stemBoundaryProb = Double.parseDouble(value);
            } else if (opt.equals("xaffixboundaryprob")) {
                affixBoundaryProb = Double.parseDouble(value);
            }
            break;
        }
    }
}

From source file:tikka.hmm.apps.CommandLineOptions.java

/**
 *
 * @param cline/* w  ww  .j a  v  a  2s  . co  m*/
 * @throws IOException
 */
public CommandLineOptions(CommandLine cline) throws IOException {

    String opt = null;

    for (Option option : cline.getOptions()) {
        String value = option.getValue();
        switch (option.getOpt().charAt(0)) {
        case 'a':
            alpha = Double.parseDouble(value);
            break;
        case 'b':
            beta = Double.parseDouble(value);
            break;
        case 'c':
            if (value.equals("conll2k")) {
                dataFormat = DataFormatEnum.DataFormat.CONLL2K;
            } else if (value.equals("hashslash")) {
                dataFormat = DataFormatEnum.DataFormat.HASHSLASH;
            } else if (value.equals("pipesep")) {
                dataFormat = DataFormatEnum.DataFormat.PIPESEP;
            } else if (value.equals("raw")) {
                dataFormat = DataFormatEnum.DataFormat.RAW;
            } else {
                System.err.println("\"" + value + "\" is an unknown data format option.");
                System.exit(1);
            }
            break;
        case 'd':
            if (value.endsWith("" + File.separator)) {
                trainDataDir = value.substring(0, value.length() - 1);
            } else {
                trainDataDir = value;
            }
            break;
        case 'e':
            experimentModel = value;
            break;
        case 'f':
            if (value.endsWith("" + File.separator)) {
                testDataDir = value.substring(0, value.length() - 1);
            } else {
                testDataDir = value;
            }
            break;
        case 'g':
            gamma = Double.parseDouble(value);
            break;
        case 'i':
            opt = option.getOpt();
            if (opt.equals("itr")) {
                numIterations = Integer.parseInt(value);
            } else if (opt.equals("ite")) {
                testSetBurninIterations = Integer.parseInt(value);
            }
            break;
        case 'j':
            if (value.endsWith("" + File.separator)) {
                annotatedTestTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTestTextOutDir = value;
            }
            break;
        case 'k':
            opt = option.getOpt();
            if (opt.equals("ks")) {
                samples = Integer.parseInt(value);
            } else if (opt.equals("kl")) {
                lag = Integer.parseInt(value);
            }
            break;
        case 'l':
            modelInputPath = value;
            break;
        case 'm':
            modelOutputPath = value;
            break;
        case 'n':
            if (value.endsWith("" + File.separator)) {
                annotatedTrainTextOutDir = value.substring(0, value.length() - 1);
            } else {
                annotatedTrainTextOutDir = value;
            }
            break;
        case 'o':
            opt = option.getOpt();
            if (opt.equals("ot")) {
                tabularOutputFilename = value;
                tabulatedOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(tabularOutputFilename)));
            } else if (opt.equals("oste")) {
                testDataSampleScoreOutputFilename = value;
                testDataSampleScoreOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(testDataSampleScoreOutputFilename)));
            } else if (opt.equals("ostr")) {
                trainDataSampleScoreOutputFilename = value;
                trainDataSampleScoreOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(trainDataSampleScoreOutputFilename)));
            } else if (opt.equals("oe")) {
                evaluationOutputFilename = value;
                evaluationOutput = new BufferedWriter(
                        new OutputStreamWriter(new FileOutputStream(evaluationOutputFilename)));
            }
            break;
        case 'p':
            opt = option.getOpt();
            if (opt.equals("pi")) {
                initialTemperature = Double.parseDouble(value);
            } else if (opt.equals("pd")) {
                temperatureDecrement = Double.parseDouble(value);
            } else if (opt.equals("pt")) {
                targetTemperature = Double.parseDouble(value);
            }
            break;
        case 'q':
            delta = Double.parseDouble(value);
            break;
        case 'r':
            randomSeed = Integer.valueOf(value);
            break;
        case 's':
            states = Integer.parseInt(value);
            break;
        case 't':
            topics = Integer.parseInt(value);
            break;
        case 'u':
            opt = option.getOpt();
            if (opt.equals("ut")) {
                if (value.equals("b")) {
                    tagSet = TagSetEnum.TagSet.BROWN;
                } else if (value.equals("p")) {
                    tagSet = TagSetEnum.TagSet.PTB;
                } else if (value.equals("t")) {
                    tagSet = TagSetEnum.TagSet.TIGER;
                }
            } else if (opt.equals("ur")) {
                int val = Integer.parseInt(value);
                if (val == 0) {
                    reductionLevel = TagSetEnum.ReductionLevel.FULL;
                } else {
                    reductionLevel = TagSetEnum.ReductionLevel.REDUCED;
                }
            }
            break;

        case 'w':
            outputPerClass = Integer.parseInt(value);
            break;
        }
    }
}

From source file:tv.icntv.log.stb.core.AbstractJob.java

@Override
public int run(String[] args) throws Exception {
    if (null == args || args.length < 1) {
        logger.error("usage :-ruleFile <rule_file>");
        return -1;
    }/*from   w  ww.jav  a 2 s.  co  m*/
    Map temp = Maps.newConcurrentMap();
    CommandLineParser parser = new PosixParser();
    CommandLine line = parser.parse(init(), args);

    for (Option option : line.getOptions()) {
        System.out.println(maps.get(option.getOpt()) + "\t" + option.getValue());
        temp.put(maps.get(option.getOpt()), option.getValue());
    }
    ;

    Configuration conf = super.getConf();

    conf.set("mapreduce.output.fileoutputformat.compress", "true");
    conf.set("mapreduce.output.fileoutputformat.compress.codec", "com.hadoop.compression.lzo.LzopCodec");
    conf.set("mapreduce.map.output.compress", "true");
    conf.set("mapreduce.map.output.compress.codec", "com.hadoop.compression.lzo.LzopCodec");
    return run(temp) ? 0 : 1;
}

From source file:vpp.Main.java

private VppOptions parseArgs() throws ParseException {
    final Option outputPathOption = new Option("o", "output-path", true,
            "The output file or directory. If not specified then the "
                    + "output is written to standard output.");

    final Option helpOption = new Option("h", "help", false, "Print help for this application and exit");

    final Options options = new Options();
    options.addOption(outputPathOption);
    options.addOption(helpOption);/*from   w w w. ja  v  a2s .c om*/

    final GnuParser parser = new GnuParser();
    final CommandLine parsedArgs = parser.parse(options, this.args);
    final VppOptions vppOptions = new VppOptions();
    final String[] leftoverArgs = parsedArgs.getArgs();

    boolean printHelp = false;
    final Option[] parsedOptions = parsedArgs.getOptions();
    for (final Option option : parsedOptions) {
        final String value = option.getValue();
        if (option.getOpt().equals(helpOption.getOpt())) {
            printHelp = true;
        } else if (option.getOpt().equals(outputPathOption.getOpt())) {
            vppOptions.setDefine(value, "{post" + value + "}");
        }
    }

    for (final String leftoverArg : leftoverArgs) {
        vppOptions.addInputPath(leftoverArg);
    }

    if (printHelp) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("[options] [input paths]", options);
        return null;
    }

    return vppOptions;
}

From source file:wvw.utils.cmd.CmdUtils.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public boolean process(String[] args) {
    if (ArrayUtils.contains(args, "-help")) {
        help();//  ww  w .  j a  v a 2s. c  o  m

        return false;
    }

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;

    try {
        cmd = parser.parse(options, args);

    } catch (ParseException e) {
        error(e);

        return false;
    }

    Option[] options = cmd.getOptions();
    for (Option option : options) {

        final String name = option.getOpt();
        CmdOption cmdOption = find(name);

        Object value = option.getValue();
        if (cmdOption.hasArg()) {

            if (value == null) {
                error("require value for option \"" + name + "\"");

                return false;
            }

            if (cmdOption.hasArgClz()) {

                if (cmdOption.getArgClz().equals(Integer.class)) {
                    try {
                        value = Integer.parseInt((String) value);

                    } catch (NumberFormatException e) {
                        error(e);

                        return false;
                    }

                } else if (cmdOption.getArgClz().equals(Double.class)) {
                    try {
                        value = Double.parseDouble((String) value);

                    } catch (NumberFormatException e) {
                        error(e);

                        return false;
                    }

                } else if (cmdOption.getArgClz().equals(String.class)) {

                } else {
                    error("unsupported argument class: " + cmdOption.getArgClzName());

                    return false;
                }
            }

            if (cmdOption.getOptions() != null) {

                if (!ArrayUtils.contains(cmdOption.getOptions(), value)) {
                    error("unsupported argument \"" + value + "\"");

                    return false;
                }
            }
        }

        if (!listener.cmdOptionValue(name, value))
            return false;
    }

    this.processedOptions = new ArrayList(Arrays.asList(options));

    if (!doPostCheck(options))
        return false;

    return true;
}

From source file:wvw.utils.cmd.CmdUtils.java

private boolean inArray(Option[] options, String name, String value) {
    for (Option option : options)
        if (option.getOpt().equals(name)
                && (value == null || (option.getValue() != null && option.getValue().equals(value))))

            return true;

    return false;
}