edu.rice.cs.drjava.config
Class OptionParser<T>

java.lang.Object
  extended by edu.rice.cs.drjava.config.OptionParser<T>
All Implemented Interfaces:
ParseStrategy<T>
Direct Known Subclasses:
Option

public abstract class OptionParser<T>
extends Object
implements ParseStrategy<T>

The association of an OptionName with the ability to parse something to type T; the intended type parameterization is covariant: if U extends T, then OptionParser extends OptionParser.


Field Summary
protected  T defaultValue
           
 String name
          The logical name of this configurable option (i.e.
 
Constructor Summary
OptionParser(String name, T def)
          Constructor that takes in a name
 
Method Summary
 T getDefault()
           
abstract  String getDefaultString()
           
 String getName()
          Accessor for name option
abstract  T parse(String value)
          The ability to parse a string to an object of type T.
 String toString()
          Returns a string representation of this OptionParser/Option suitable for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final String name
The logical name of this configurable option (i.e. "indent.size") public because it's final, and a String is immutable.


defaultValue

protected final T defaultValue
Constructor Detail

OptionParser

public OptionParser(String name,
                    T def)
Constructor that takes in a name

Parameters:
name - the name of this option (i.e. "indent.level");
Method Detail

getName

public String getName()
Accessor for name option

Returns:
name of this option (i.e. "indent.level")

getDefault

public T getDefault()
Returns:
the default value

getDefaultString

public abstract String getDefaultString()
Returns:
the default value as a string

parse

public abstract T parse(String value)
The ability to parse a string to an object of type T. All concrete versions of this class must override this method to provide some sort of parser implementation.

Specified by:
parse in interface ParseStrategy<T>
Parameters:
value - a String to parse
Returns:
the statically-typed representation of the string value.

toString

public String toString()
Returns a string representation of this OptionParser/Option suitable for debugging.

Overrides:
toString in class Object