laser.util.argument
Class Option

java.lang.Object
  extended by laser.util.argument.Argument
      extended by laser.util.argument.Option
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BooleanOption, ChoiceOption, ClassOption, FloatOption, IntegerOption, LongOption, StringOption

public abstract class Option
extends Argument

The Option class defines a user-defined option. An option has:

The value and default value should be of the same type.

Author:
Heather M. Conboy (laser-software@cs.umass.edu)
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_PREFIX
          The help default prefix
static java.lang.String DEFAULT_SUFFIX
          The help default suffix
static char NOT_REPEATABLE_CHAR
          Signals the Option is not repeatable
static char REPEATABLE_CHAR
          Signals the Option is repeatable
 
Fields inherited from class laser.util.argument.Argument
FIRST, HELP_DEFAULT, HELP_PREFIX, REPEATABLE_DEFAULT, TYPE_PREFIX, TYPE_SUFFIX
 
Constructor Summary
protected Option(java.lang.String name, java.lang.Object defaultValue)
          Creates a new Option with the given name and default value.
protected Option(java.lang.String name, java.lang.Object defaultValue, boolean isRepeatable, java.lang.String helpMessage)
          Creates a new Option with the given name and default value.
 
Method Summary
protected  java.lang.Object getDefault()
          Gets the default value of this Option.
protected abstract  java.lang.String getDefaultString()
          Gets the default string which describes the default value of this Option.
 java.lang.String getHelp()
          Gets the help for this Option.
 char getRepeatableChar()
          Gets the repeatable character.
 java.lang.Object getValue(int index)
          Gets the value of this Option at the specified index.
 int numberOfValues()
          Gets the number of values for this Argument.
 
Methods inherited from class laser.util.argument.Argument
check, checkValue, clear, clone, equals, fromStringValue, getHelpMessage, getName, getType, getValue, getValues, initialize, isRepeatable, numberOfActualValues, parseValue, save, setValue, toString, toStringValue, toStringValue
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PREFIX

public static final java.lang.String DEFAULT_PREFIX
The help default prefix

See Also:
Constant Field Values

DEFAULT_SUFFIX

public static final java.lang.String DEFAULT_SUFFIX
The help default suffix

See Also:
Constant Field Values

REPEATABLE_CHAR

public static final char REPEATABLE_CHAR
Signals the Option is repeatable

See Also:
Constant Field Values

NOT_REPEATABLE_CHAR

public static final char NOT_REPEATABLE_CHAR
Signals the Option is not repeatable

See Also:
Constant Field Values
Constructor Detail

Option

protected Option(java.lang.String name,
                 java.lang.Object defaultValue,
                 boolean isRepeatable,
                 java.lang.String helpMessage)
Creates a new Option with the given name and default value. It will be multi-valued if isRepeatable is true and single-valued otherwise. The help message will be made available to the user upon request.

Parameters:
name - The name for the option
defaultValue - The value of the option if the user doesn't specify a value
isRepeatable - If true then this option is multi-valued otherwise it is single-valued
helpMessage - The help message to report to the user upon request

Option

protected Option(java.lang.String name,
                 java.lang.Object defaultValue)
Creates a new Option with the given name and default value. It will have the default setting for isRepeatable and helpMessage.

Parameters:
name - The name for the option
defaultValue - The value of the option if the user doesn't specify a value
See Also:
Argument.REPEATABLE_DEFAULT, Argument.HELP_DEFAULT
Method Detail

numberOfValues

public int numberOfValues()
Gets the number of values for this Argument.

NOTE: There is always at least one value since there is a default value.

Overrides:
numberOfValues in class Argument
Returns:
The number of values

getValue

public java.lang.Object getValue(int index)
Gets the value of this Option at the specified index.

NOTE: All options will have at least one value at index Argument.FIRST.

Overrides:
getValue in class Argument
Parameters:
index - The index of the value
Returns:
The value at index

getDefault

protected java.lang.Object getDefault()
Gets the default value of this Option.

Returns:
The default value

getDefaultString

protected abstract java.lang.String getDefaultString()
Gets the default string which describes the default value of this Option.

Returns:
The default string description

getRepeatableChar

public char getRepeatableChar()
Gets the repeatable character.

Specified by:
getRepeatableChar in class Argument
Returns:
The repeatable character

getHelp

public java.lang.String getHelp()
Gets the help for this Option.

Overrides:
getHelp in class Argument
Returns:
The help