Example usage for org.apache.commons.cli2 CommandLine getSwitch

List of usage examples for org.apache.commons.cli2 CommandLine getSwitch

Introduction

In this page you can find the example usage for org.apache.commons.cli2 CommandLine getSwitch.

Prototype

Boolean getSwitch(final Option option);

Source Link

Document

Retrieves the Boolean value associated with the specified Switch

Usage

From source file:de.tu_chemnitz.mi.barcd.app.CommandLineArgumentsParser.java

/**
 * @param args the arguments as passed to a main function
 *
 * @return the parsed options, null if the arguments could no be parsed
 *///from   w  w w  . java 2s.c om
public Options parse(String[] args) {
    CommandLine commandLine = parser.parseAndHelp(args);
    if (commandLine == null) {
        return null;
    }
    Options options = new Options();
    options.setJobFile((File) commandLine.getValue("--job"));
    options.setXmlSchemaUrl((URL) commandLine.getValue("--xml-schema"));
    options.setDisplay(commandLine.getSwitch("+display"));
    options.setPersist(commandLine.getSwitch("+persist"));
    return options;
}