TUM CCSM Commons

Package edu.tum.cs.commons.options

Classes for simplifying command line parsing.

See:
          Description

Class Summary
AOptionComparator A comparator for ordering options in a way used for usage messages.
CmdLine Deprecated. Use the CommandLine class instead.
CommandLine A class providing command line parsing and usage messages using GNU syntax.
CommandLineTokenStream This class preprocesses the command line arguments by splitting them into several tokens.
OptionRegistry This class supports collecting options from several objects whose methods have been annotated with AOption.
Options This class offers a safe and flexible interface to Java properties files.
 

Exception Summary
OptionException Base class for exceptions occuring while parsing options.
Options.ValueConversionException Exception objects of this class are possibly returned by Options.getBooleanValue(String)and Options.getIntValue(String), if corresponding options don't have a boolean respectively integer value.
 

Annotation Types Summary
AOption Annotation for exposing methods as command line options.
 

Package edu.tum.cs.commons.options Description

Classes for simplifying command line parsing. The general idea is to annotate methods with AOption, which are then exposed as command line switches. Whether the option takes an argument (and the type of the argument) is determined by the arguments the method accepts. Additional constraints on the option arguments (e.g. value positive) can be enforced by the method by throwing an IllegalArgumentException.

The options are extracted and collected by an OptionRegistry. The OptionRegistry extracts methods annotated with AOption and keeps them as OptionApplicators for later use. To support the distribution of option handling over multiple classes (e.g. to separate options affecting different parts of the architecture) multiple objects can be registered with the registry.

The actual parsing of the command line is performed by the CommandLine. This is to separate the low level part (annotations and reflection) from the parser. Additionally this way the parser can easily be extended or exchanged.

As an example for using these classes see the edu.tum.cs.conqat.driver.Driver class in the ConQAT project.


TUM CCSM Commons

TUM CCSM Commons - 2.7