dsto.dfc.commandline
Class Option

java.lang.Object
  extended by dsto.dfc.commandline.Option
Direct Known Subclasses:
BooleanOption, IntegerOption, PluginOption, StringOption

public abstract class Option
extends Object

Representation of a command-line option


Field Summary
protected  String value
           
 
Constructor Summary
protected Option(char shortForm, String longForm, boolean wantsValue)
           
 
Method Summary
 Object getValue()
           
 Object getValue(String arg)
          Returns the value of this option if the option actually has a value associated with it, or else it returns Boolean.TRUE.
 String longForm()
          return the longForm representation of this option.
protected  Object parseValue(String arg)
          Override to extract and convert an option value passed on the command-line
protected  void setValue(String value)
           
 String shortForm()
          return the shortForm representation of this option.
 boolean wantsValue()
          Tells whether or not this option wants a value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected String value
Constructor Detail

Option

protected Option(char shortForm,
                 String longForm,
                 boolean wantsValue)
Parameters:
shortForm - A single character representation of the option. eg 'f' for "-f"
longForm - A string representation of the option. eg "file" for "--file"
wantsValue - If this is set to true then the option requires a value after it. eg "--file blah.txt"
Method Detail

shortForm

public String shortForm()
return the shortForm representation of this option.


longForm

public String longForm()
return the longForm representation of this option.


wantsValue

public boolean wantsValue()
Tells whether or not this option wants a value


getValue

public final Object getValue(String arg)
                      throws IllegalOptionValueException
Returns the value of this option if the option actually has a value associated with it, or else it returns Boolean.TRUE.

Throws:
IllegalOptionValueException - This gets thrown if the arg is null.

getValue

public Object getValue()

setValue

protected void setValue(String value)

parseValue

protected Object parseValue(String arg)
                     throws IllegalOptionValueException
Override to extract and convert an option value passed on the command-line

Throws:
IllegalOptionValueException


Copyright © 2008 Commonwealth of Australia