ds.ov2.util
Class Option

java.lang.Object
  extended by ds.ov2.util.Option
Direct Known Subclasses:
BigInt_hex_input_option, BigInt_input_option, Bool_option, Int_option, String_option, Value_option

public abstract class Option
extends Object

Abstract command line option. Internally an option is almost a record with one method. The record stores the option string and the documentation. All this data is accessed from Parse_commandline, which contains all the machinery for parsing command lines. The only method in an option is matched, which is called by Parse_commandline when the option has been recognized on the command line.

Clients need to override matched with some code that records the option and its possible arguments somewhere.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.1 $
Last Commit:
$Date: 2009-06-02 09:56:03 $ by $Author: tews $

Field Summary
 String argument
          A string describing arguments, if any.
 String explanation
          The explanation of the option, to be printed in the usage information.
 String option
          The literally option string as it appears on the command line.
 
Constructor Summary
Option(String option, String argument, String explanation)
          Construct a new abstract option.
 
Method Summary
abstract  void matched(Commandline cl)
          Called by the option parsing machinery in Parse_commandline when this option has been recognized on the command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

option

public final String option
The literally option string as it appears on the command line.


argument

public final String argument
A string describing arguments, if any. See explanation for more information.


explanation

public final String explanation
The explanation of the option, to be printed in the usage information. The usage information consists of one line for each option, for instance
    -h      print help
    -i n    int argument n
 
To ease formatting of the usage information, option arguments (such as the n in the example) are kept seperately in the field argument. The explanation in the right hand column is kept in this field.

See also Parse_commandline.usage().

Constructor Detail

Option

public Option(String option,
              String argument,
              String explanation)
Construct a new abstract option. Initialize the fields.

Parameters:
option - the literal option string as it will appear on the command line
argument - a string describing any arguments of the option, for the usuage information; might be null or the empty string for no arguments
explanation - explanation for the usuage information
Method Detail

matched

public abstract void matched(Commandline cl)
Called by the option parsing machinery in Parse_commandline when this option has been recognized on the command line. When called the command line object points to the next unprocessed element of the command line. If this option has arguments, it must retrieve them from cl and advance the index therein such that it points to the next unprocessed options when this method exits.

If the option is illegal in the current state or if its argument are missing or are of the wrong format, the method should print an appropriate error message and exit the program.

Parameters:
cl - command line instance; its index points to the next unprocessed command line element
Throws:
Option_error