org.apache.commons.cli

Class Parser

public abstract class Parser extends Object implements CommandLineParser

Parser creates CommandLines.

Version: $Revision: 1.7 $

Author: John Keyes (john at integralsource.com)

See Also: Parser

Field Summary
CommandLinecmd
commandline instance
Optionsoptions
current Options
ListrequiredOptions
list of required options strings
Method Summary
voidcheckRequiredOptions()

Throws a MissingOptionException if all of the required options are no present.

protected abstract String[]flatten(Options opts, String[] arguments, boolean stopAtNonOption)

Subclasses must implement this method to reduce the arguments that have been passed to the parse method.

CommandLineparse(Options options, String[] arguments)

Parses the specified arguments based on the specifed Options.

CommandLineparse(Options opts, String[] arguments, boolean stopAtNonOption)

Parses the specified arguments based on the specifed Options.

voidprocessArgs(Option opt, ListIterator iter)
voidprocessOption(String arg, ListIterator iter)

Field Detail

cmd

private CommandLine cmd
commandline instance

options

private Options options
current Options

requiredOptions

private List requiredOptions
list of required options strings

Method Detail

checkRequiredOptions

private void checkRequiredOptions()

Throws a MissingOptionException if all of the required options are no present.

flatten

protected abstract String[] flatten(Options opts, String[] arguments, boolean stopAtNonOption)

Subclasses must implement this method to reduce the arguments that have been passed to the parse method.

Parameters: opts The Options to parse the arguments by. args The arguments that have to be flattened. stopAtNonOption specifies whether to stop flattening when a non option has been encountered

Returns: a String array of the flattened arguments

parse

public CommandLine parse(Options options, String[] arguments)

Parses the specified arguments based on the specifed Options.

Parameters: options the Options arguments the arguments

Returns: the CommandLine

Throws: ParseException if an error occurs when parsing the arguments.

parse

public CommandLine parse(Options opts, String[] arguments, boolean stopAtNonOption)

Parses the specified arguments based on the specifed Options.

Parameters: options the Options arguments the arguments stopAtNonOption specifies whether to stop interpreting the arguments when a non option has been encountered and to add them to the CommandLines args list.

Returns: the CommandLine

Throws: ParseException if an error occurs when parsing the arguments.

processArgs

public void processArgs(Option opt, ListIterator iter)

processOption

private void processOption(String arg, ListIterator iter)