|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.drjava.config.OptionParser<T>
edu.rice.cs.drjava.config.Option<T>
public abstract class Option<T>
An instance of this class represents a configurable option in DrJava that has static type T. Classes can extend this class and the rest of the Configuration typing framework will work for it. Named subclasses aren't even necessary -- but may be convenient in order to re-use code. For example, to make an anonymous class that handles options of static type Integer, with the name "indent.level", you could use the following code:
Option<Integer> INDENT_LEVEL = new Option<Integer>("indent.level") {
public Integer parse(String s) {
return new Integer(s);
}
};
The precedinjg example is simple because Integers (like most data-type classes defined in the Java
libraries) have handy toString() / parsing methods/constructors.
| Field Summary | |
|---|---|
(package private) HashMap<Configuration,Vector<OptionListener<T>>> |
listeners
A hashtable that maps Configuration objects to a list of listeners for this particular option. |
| Fields inherited from class edu.rice.cs.drjava.config.OptionParser |
|---|
defaultValue, map, name |
| Constructor Summary | |
|---|---|
Option(String name,
T def)
Constructor that takes in a name and default value |
|
| Method Summary | |
|---|---|
(package private) void |
addListener(Configuration c,
OptionListener<T> l)
Magic listener-bag adder |
String |
format(T value)
Formats a statically typed T value as a String. |
String |
getDefaultString()
|
(package private) String |
getString(DefaultOptionMap om)
Uses format() and getOption() so that any changes in format will automatically be applied to getString(). |
(package private) void |
notifyListeners(Configuration config,
T val)
Sends an OptionEvent to all OptionListeners who have registered on this Option. |
(package private) void |
removeListener(Configuration c,
OptionListener<T> l)
Magic listener-bag remover |
| Methods inherited from class edu.rice.cs.drjava.config.OptionParser |
|---|
getDefault, getName, getOption, parse, remove, setOption, setString, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
final HashMap<Configuration,Vector<OptionListener<T>>> listeners
| Constructor Detail |
|---|
public Option(String name,
T def)
name - the name of this option (eg. "indent.level");def - the default value for this option (eg. "2")| Method Detail |
|---|
public String format(T value)
format in interface FormatStrategy<T>value - the statically-typed value to format into a String
NullPointerException - if value is nullpublic String getDefaultString()
getDefaultString in class OptionParser<T>String getString(DefaultOptionMap om)
getString in class OptionParser<T>
void notifyListeners(Configuration config,
T val)
void addListener(Configuration c,
OptionListener<T> l)
void removeListener(Configuration c,
OptionListener<T> l)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||