edu.rice.cs.drjava.config
Class OptionParser

java.lang.Object
  |
  +--edu.rice.cs.drjava.config.OptionParser
All Implemented Interfaces:
ParseStrategy
Direct Known Subclasses:
Option

public abstract class OptionParser
extends Object
implements ParseStrategy

the association of an OptionName with the ability to parse something to type T the special property is that if U extends T, then OptionParser extends OptionParser.


Field Summary
private  Object defaultValue
           
(package private)  gj.util.Hashtable map
          an inner hashtable that maps DefaultOptionMaps to value T's.
 String name
          The logical name of this configurable option (i.e.
 
Constructor Summary
OptionParser(String name, Object def)
          constructor that takes in a name
 
Method Summary
 Object getDefault()
           
abstract  String getDefaultString()
           
 String getName()
          accessor for name option
(package private)  Object getOption(DefaultOptionMap om)
          the accessor for the magic-typed hashtable stunt.
(package private) abstract  String getString(DefaultOptionMap om)
           
abstract  Object parse(String value)
          the ability to parse a string to an object of type T.
(package private)  Object remove(DefaultOptionMap om)
          the destructor for a mapping in the magic-typed hashtable.
(package private)  Object setOption(DefaultOptionMap om, Object val)
          the mutator for the magic-typed hashtable stunt.
(package private)  Object setString(DefaultOptionMap om, String val)
          uses parse() and setOption() so that any changes in parsing will automatically be applied to setString().
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, 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

private final Object defaultValue

map

final gj.util.Hashtable map
an inner hashtable that maps DefaultOptionMaps to value T's. part of the magic inner workings of this package.
Constructor Detail

OptionParser

public OptionParser(String name,
                    Object 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 Object getDefault()
Returns:
the default value

getDefaultString

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

parse

public abstract Object 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
Parameters:
value - a String to parse
Returns:
the statically-typed representation of the string value.

getString

abstract String getString(DefaultOptionMap om)

setString

Object setString(DefaultOptionMap om,
                 String val)
uses parse() and setOption() so that any changes in parsing will automatically be applied to setString().

getOption

Object getOption(DefaultOptionMap om)
the accessor for the magic-typed hashtable stunt.

setOption

Object setOption(DefaultOptionMap om,
                 Object val)
the mutator for the magic-typed hashtable stunt.

remove

Object remove(DefaultOptionMap om)
the destructor for a mapping in the magic-typed hashtable.