edu.rice.cs.drjava.config
Class Configuration

java.lang.Object
  extended by edu.rice.cs.drjava.config.Configuration
Direct Known Subclasses:
SavableConfiguration

public class Configuration
extends Object

Class to store and retrieve all configurable options.

Version:
$Id: Configuration.java 4544 2008-07-08 06:59:53Z rcartwright $

Field Summary
protected  Exception _startupException
          Any exception that is caught when initializing this Configuration object.
protected  OptionMap map
          OptionMap used to store all option settings.
 
Constructor Summary
Configuration(OptionMap om)
          Initializes this Configuration object with the given OptionMap.
 
Method Summary
<T> void
addOptionListener(Option<T> op, OptionListener<T> l)
          Adds an OptionListener to the given Option, to be notified each time the option changes.
 OptionMap getOptionMap()
          Return OptionMap.
<T> T
getSetting(Option<T> op)
          Gets the current value of the given Option.
 Exception getStartupException()
          Returns the exception caught during startUp, or null if none were caught.
 boolean hadStartupException()
          Returns whether there were any exceptions when starting.
<T> void
removeOptionListener(Option<T> op, OptionListener<T> l)
          Removes an OptionListener from an Option to which it was listening.
 void resetToDefaults()
          Resets to the default values, overwriting any existing values.
<T> T
setSetting(Option<T> op, T value)
          Sets the given option to the given value and notifies all listeners of that option of the change.
 void storeStartupException(Exception e)
          Stores exception caught during creation of this Configuration object, so it can be displayed later by the UI.
 String toString()
          Returns a string representation of the contents of the OptionMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected volatile OptionMap map
OptionMap used to store all option settings.


_startupException

protected volatile Exception _startupException
Any exception that is caught when initializing this Configuration object. Used later by the UI to display a useful message to the user.

Constructor Detail

Configuration

public Configuration(OptionMap om)
Initializes this Configuration object with the given OptionMap.

Parameters:
om - An empty OptionMap.
Method Detail

setSetting

public <T> T setSetting(Option<T> op,
                        T value)
Sets the given option to the given value and notifies all listeners of that option of the change.

Parameters:
op - Option to set
value - New value for the option

getSetting

public <T> T getSetting(Option<T> op)
Gets the current value of the given Option.


addOptionListener

public <T> void addOptionListener(Option<T> op,
                                  OptionListener<T> l)
Adds an OptionListener to the given Option, to be notified each time the option changes.

Parameters:
op - Option to listen for changes on
l - OptionListener wishing to listen

removeOptionListener

public <T> void removeOptionListener(Option<T> op,
                                     OptionListener<T> l)
Removes an OptionListener from an Option to which it was listening.


resetToDefaults

public void resetToDefaults()
Resets to the default values, overwriting any existing values.


hadStartupException

public boolean hadStartupException()
Returns whether there were any exceptions when starting.


getStartupException

public Exception getStartupException()
Returns the exception caught during startUp, or null if none were caught.


storeStartupException

public void storeStartupException(Exception e)
Stores exception caught during creation of this Configuration object, so it can be displayed later by the UI.

Parameters:
e - Exception caught during startUp

toString

public String toString()
Returns a string representation of the contents of the OptionMap.

Overrides:
toString in class Object

getOptionMap

public OptionMap getOptionMap()
Return OptionMap.