edu.rice.cs.drjava.config
Class PropertyMaps

java.lang.Object
  extended by edu.rice.cs.drjava.config.PropertyMaps
All Implemented Interfaces:
Cloneable

public class PropertyMaps
extends Object
implements Cloneable

Class representing all the variables that can be inserted as variables in external processes.

Version:
$Id$

Field Summary
protected  Map<String,Map<String,DrJavaProperty>> _props
          Map of property sets.
protected  HashMap<String,Stack<VariableProperty>> _variables
           
static Lambda2<DrJavaProperty,PropertyMaps,String> GET_CURRENT
          A lambda to use the getCurrent() method, which forces an update.
static Lambda2<DrJavaProperty,PropertyMaps,String> GET_LAZY
          A lambda to use the getLazy() method, which does not force an update and might be stale.
static PropertyMaps TEMPLATE
          Template instance.
protected static String VARIABLES_CATEGORY
           
 
Constructor Summary
PropertyMaps()
          Create the basic property maps.
 
Method Summary
 void addVariable(String name, String value)
          Add a variable with the specified name and value, shadowing previous definitions of the variable.
 void clearCategory(String category)
          Clear the specified category.
 void clearVariables()
          Clear all user-defined variables.
 PropertyMaps clone()
          Clone this PropertyMaps object.
 Set<String> getCategories()
          Return the set of categories.
 Map<String,DrJavaProperty> getProperties(String category)
          Return the properties in a category.
 DrJavaProperty getProperty(String key)
          Search through all categories and return the property requested, or null if not found.
 DrJavaProperty getProperty(String category, String name)
          Return the property requested, or null if not found.
 void removeProperty(DrJavaProperty p)
          Remove the specified property.
 void removeVariable(String name)
          Remove the variable with the specified name, unshadowing previous definitions of the variable.
 DrJavaProperty setProperty(String category, DrJavaProperty p)
          Add a property.
 void setVariable(String name, String value)
          Mutate the value of a variable with the specified name.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_props

protected Map<String,Map<String,DrJavaProperty>> _props
Map of property sets.


TEMPLATE

public static final PropertyMaps TEMPLATE
Template instance.


GET_LAZY

public static final Lambda2<DrJavaProperty,PropertyMaps,String> GET_LAZY
A lambda to use the getLazy() method, which does not force an update and might be stale.


GET_CURRENT

public static final Lambda2<DrJavaProperty,PropertyMaps,String> GET_CURRENT
A lambda to use the getCurrent() method, which forces an update.


_variables

protected HashMap<String,Stack<VariableProperty>> _variables

VARIABLES_CATEGORY

protected static final String VARIABLES_CATEGORY
See Also:
Constant Field Values
Constructor Detail

PropertyMaps

public PropertyMaps()
Create the basic property maps. One is named "Java" and contains the Java system properties. A second one is named "Config" and contains the DrJava configuration items.

Method Detail

getProperty

public DrJavaProperty getProperty(String category,
                                  String name)
Return the property requested, or null if not found.

Parameters:
category - name of the category
name - name of the property
Returns:
property, or null if not found
Throws:
IllegalArgumentException - if category is not known.

getProperty

public DrJavaProperty getProperty(String key)
Search through all categories and return the property requested, or null if not found.

Parameters:
key - key of the property
Returns:
property, or null if not found

removeProperty

public void removeProperty(DrJavaProperty p)
Remove the specified property.

Parameters:
p - property to remove

setProperty

public DrJavaProperty setProperty(String category,
                                  DrJavaProperty p)
Add a property.


clearCategory

public void clearCategory(String category)
Clear the specified category.


getCategories

public Set<String> getCategories()
Return the set of categories.


getProperties

public Map<String,DrJavaProperty> getProperties(String category)
Return the properties in a category.

Throws:
IllegalArgumentException - if category is not known.

clearVariables

public void clearVariables()
Clear all user-defined variables.


addVariable

public void addVariable(String name,
                        String value)
Add a variable with the specified name and value, shadowing previous definitions of the variable.

Parameters:
name - name of the variable
value - value of the variable
Throws:
IllegalArgumentException - if the name is already used for a built-in property

setVariable

public void setVariable(String name,
                        String value)
Mutate the value of a variable with the specified name.

Parameters:
name - name of the variable
value - new value of the variable
Throws:
IllegalArgumentException - if a variable with name does not exist

removeVariable

public void removeVariable(String name)
Remove the variable with the specified name, unshadowing previous definitions of the variable.

Parameters:
name - of the variable
Throws:
IllegalArgumentException - if no variable with that name exists

clone

public PropertyMaps clone()
                   throws CloneNotSupportedException
Clone this PropertyMaps object.

Overrides:
clone in class Object
Returns:
cloned object
Throws:
CloneNotSupportedException