common.cmdline
Interface Option

All Known Implementing Classes:
AbstractOption, BooleanOption, DoubleOption, IntOption, PropertiesOption, StringListOption, StringOption

public interface Option

Interface for command line options. This interface is solely for interaction with the command line parser. The application will also need to create Option objects, and query them to find out whether they occurred and (if so) with what values. However, each Option implementation defines its own methods for those purposes.

All Option implementations should called Parser.add(this) in their constructors, once they have fully set up their lists of long and short forms.


Method Summary
 boolean expectsValue()
          Returns true if this option expects a value on the command line.
 java.util.List getLongForms()
          Returns the long forms of this option.
 java.util.List getShortForms()
          Returns the short (single-character) forms of this option.
 java.lang.String getUsageString()
          Returns a string that documents the option.
 void recordOccurrence(java.lang.String form, java.lang.String valueStr)
          Records an occurrence of this option with the given value.
 

Method Detail

getShortForms

java.util.List getShortForms()
Returns the short (single-character) forms of this option.

Returns:
List of Character objects

getLongForms

java.util.List getLongForms()
Returns the long forms of this option.

Returns:
List of String objects

expectsValue

boolean expectsValue()
Returns true if this option expects a value on the command line.


recordOccurrence

void recordOccurrence(java.lang.String form,
                      java.lang.String valueStr)
Records an occurrence of this option with the given value. The form argument specifies the particular long or short form of the option that was used. If the value is invalid, or if the option has already occurred and a second occurrence is not allowed, this method may print an error message and exit the program.

Parameters:
form - specifies the particular long or short form of the option that was used
valueStr - the given value, or null if no value was given. The parser will only pass null for this parameter if expectsValue returns false; otherwise, if the value is missing, the parser will not call this method.

getUsageString

java.lang.String getUsageString()
Returns a string that documents the option. This string should fit on one 80-column line.