net.dpml.cli.commandline
Class Parser

java.lang.Object
  extended by net.dpml.cli.commandline.Parser

public class Parser
extends Object

A class that implements the Parser interface can parse a String array according to the Groupspecified and return a CommandLine.

Version:
1.0.0
Author:
Digital Product Meta Library

Constructor Summary
Parser()
           
 
Method Summary
 CommandLine parse(String[] arguments)
          Parse the arguments according to the specified options and properties.
 CommandLine parseAndHelp(String[] arguments)
          Parse the arguments according to the specified options and properties and displays the usage screen if the CommandLine is not valid or the help option was specified.
 void setGroup(Group group)
          Sets the Group of options to parse against
 void setHelpFormatter(HelpFormatter helpFormatter)
          Sets the HelpFormatter to use with the simplified parsing.
 void setHelpOption(Option helpOption)
          Sets the help option to use with the simplified parsing.
 void setHelpTrigger(String helpTrigger)
          Sets the help option to use with the simplified parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser()
Method Detail

parse

public CommandLine parse(String[] arguments)
                  throws OptionException
Parse the arguments according to the specified options and properties.

Parameters:
arguments - the command line arguments
Returns:
the list of atomic option and value tokens
Throws:
OptionException - if there are any problems encountered while parsing the command line tokens.

parseAndHelp

public CommandLine parseAndHelp(String[] arguments)
                         throws IOException
Parse the arguments according to the specified options and properties and displays the usage screen if the CommandLine is not valid or the help option was specified.

Parameters:
arguments - the command line arguments
Returns:
a valid CommandLine or null if the parse was unsuccessful
Throws:
IOException - if an error occurs while formatting help

setGroup

public void setGroup(Group group)
Sets the Group of options to parse against

Parameters:
group - the group of options to parse against

setHelpFormatter

public void setHelpFormatter(HelpFormatter helpFormatter)
Sets the HelpFormatter to use with the simplified parsing.

Parameters:
helpFormatter - the HelpFormatter to use with the simplified parsing
See Also:
parseAndHelp(String[])

setHelpOption

public void setHelpOption(Option helpOption)
Sets the help option to use with the simplified parsing. For example --help, -h and -? are often used.

Parameters:
helpOption - the help Option
See Also:
parseAndHelp(String[])

setHelpTrigger

public void setHelpTrigger(String helpTrigger)
Sets the help option to use with the simplified parsing. For example --help, -h and -? are often used.

Parameters:
helpTrigger - the trigger of the help Option
See Also:
parseAndHelp(String[])