ds.ov2.util
Class Int_option

java.lang.Object
  extended by ds.ov2.util.Option
      extended by ds.ov2.util.Int_option
Direct Known Subclasses:
Bool_int_option

public class Int_option
extends Option

Command line switch with an integer argument. When the option is found the integer value is recorded in a reference.

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
private  Reference<Integer> ref
          The int reference to set.
 
Fields inherited from class ds.ov2.util.Option
argument, explanation, option
 
Constructor Summary
Int_option(String option, Reference<Integer> ref, String argument, String explanation)
          Construct an integer option.
 
Method Summary
 int get_int_argument(Commandline cl)
          Parse an int argument from the command line.
 void matched(Commandline cl)
          Called when the option is recognized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ref

private Reference<Integer> ref
The int reference to set.

Constructor Detail

Int_option

public Int_option(String option,
                  Reference<Integer> ref,
                  String argument,
                  String explanation)
Construct an integer option. When found on the command line, the reference ref will be set to the value of the int argument.

Parameters:
option - the literal option string as it will appear on the command line
ref - the int reference
argument - name of the argument for the explanation
explanation - explanation for the usage information
Method Detail

get_int_argument

public int get_int_argument(Commandline cl)
Parse an int argument from the command line. Tries to convert the next unprocessed command line element to an integer. Displays an error message and terminates the application if there is no next command line element or if it cannot be converted to an integer. If successful the index Commandline.next_option in cl of the next unprocessed command line element is incremented.

Parameters:
cl - command line instance
Returns:
next unprocessed option converted to int if possible

matched

public void matched(Commandline cl)
Called when the option is recognized. Converts the next command line element to an integer and puts it into ref. Prints an error and exits the program on any problem.

Specified by:
matched in class Option
Parameters:
cl - command line instance