avrora.util
Class Option

java.lang.Object
  extended byavrora.util.Option
Direct Known Subclasses:
Option.Bool, Option.Double, Option.Interval, Option.List, Option.Long, Option.Str

public abstract class Option
extends java.lang.Object

The Option class represents an option that has been given on the command line. The inner classes represent specific types of options such as integers, booleans, and strings.

See Also:
Options

Nested Class Summary
static class Option.Bool
          The Option.Bool class is an implementation of the Option class that encapsulates a boolean.
static class Option.Double
          The Option.Double class is an implementation of the Option class that encapsulates a double value.
static class Option.Interval
          The Option.Long class is an implementation of the Option class that encapsulates a long integer value.
static class Option.List
          The Option.List class is an implementation of the Option class that encapsulates a list.
static class Option.Long
          The Option.Long class is an implementation of the Option class that encapsulates a long integer value.
static class Option.Str
          The Option.Str class is an implementation of the Option class that encapsulates a string.
 
Field Summary
static java.util.Comparator COMPARATOR
          The OptionComparator is an implementation of the java.util.Comparator interface that is used to sort options alphabetically for printing in the help system.
protected  java.lang.String description
          The description field stores a reference to the string that represents the help item for this option.
protected  java.lang.String name
          The name field stores a reference to the string name of this option.
 
Constructor Summary
Option(java.lang.String n, java.lang.String d)
          The constructor of the Option class creates a new option with the specified name and description.
 
Method Summary
 java.lang.String getName()
          The getName() method returns the string name of the option.
protected  void parseError(java.lang.String name, java.lang.String type, java.lang.String val)
          The parseError() method is called by an option implementation when there is a problem parsing the value for an option supplied by the user on the command line.
 void printDescription()
          The printDescription() method prints out a well-formatted representation of the description of the item to the terminal.
 void printHeader(java.lang.String type, java.lang.String defvalue)
          The printHeader() method prints out the first line of the help text for this item.
abstract  void printHelp()
          The printHelp() method prints out a textual paragraph of the help item for this option to the terminal.
abstract  void set(java.lang.String val)
          The set() method updates the value of the option.
abstract  java.lang.String stringValue()
          The stringValue() method returns a string representation of the value of the option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name
The name field stores a reference to the string name of this option.


description

protected final java.lang.String description
The description field stores a reference to the string that represents the help item for this option.


COMPARATOR

public static final java.util.Comparator COMPARATOR
The OptionComparator is an implementation of the java.util.Comparator interface that is used to sort options alphabetically for printing in the help system.

Constructor Detail

Option

public Option(java.lang.String n,
              java.lang.String d)
The constructor of the Option class creates a new option with the specified name and description.

Parameters:
n - a string name of the option
d - the description, as an unformatted string, of the help item for this option
Method Detail

getName

public java.lang.String getName()
The getName() method returns the string name of the option. This name is the same name used at the command line; i.e. -name=value.

Returns:
a string that is the name of this option

set

public abstract void set(java.lang.String val)
The set() method updates the value of the option. It is passed a string that is converted to the option's value by each respective option implementation. For example, an integer option converts the string from an integer into an integer value.

Parameters:
val - the string value passed at the command line

stringValue

public abstract java.lang.String stringValue()
The stringValue() method returns a string representation of the value of the option. This is used in debugging and reporting purposes.

Returns:
a string representation of the value of the option.

printHelp

public abstract void printHelp()
The printHelp() method prints out a textual paragraph of the help item for this option to the terminal.


printDescription

public void printDescription()
The printDescription() method prints out a well-formatted representation of the description of the item to the terminal.


printHeader

public void printHeader(java.lang.String type,
                        java.lang.String defvalue)
The printHeader() method prints out the first line of the help text for this item. This includes the option's name, type, and its default value.

Parameters:
type - the type of the item as a string
defvalue - the default value for the item as a string

parseError

protected void parseError(java.lang.String name,
                          java.lang.String type,
                          java.lang.String val)
The parseError() method is called by an option implementation when there is a problem parsing the value for an option supplied by the user on the command line. For example, if an integer is not in the correct format, this method will be called, which will report an error.

Parameters:
name - the name of the option
val - the (invalid) value passed