com.sun.electric.tool.user.projectSettings
Class ProjSettingsNode

java.lang.Object
  extended by com.sun.electric.tool.user.projectSettings.ProjSettingsNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ProjSettings.TestExtendNode

public class ProjSettingsNode
extends java.lang.Object
implements java.io.Serializable

A basic class to hold information on project settings. This node holds key-value pairs, who values are typically restricted to a few primitive types, and other ProjSettingNodes.

This class may be used as is, or may be extended to provide additional, more specific methods for setting/getting project settings. Only settings accessible by this class' methods will be written to disk. Additionally, the extended class must be public, so that it can be created when the settings are read from a file.

Settings are written to the file in the order they are added to this class. This order is consistent and deterministic, and is not sorted after being added.

This class also retains the first setting for any key. This allows the user to get the "initial" or "factory" setting, which is always the first setting applied.

See Also:
Serialized Form

Nested Class Summary
static class ProjSettingsNode.UninitializedPref
           
 
Method Summary
static java.lang.String describeContext(java.util.Stack<java.lang.String> context)
           
static boolean equal(java.lang.Object value, Setting setting)
          Compare a project settings value against a Setting object value.
 boolean equals(java.lang.Object node)
           
protected  java.lang.Object get(java.lang.String key)
           
 java.util.Set<java.lang.String> getKeys()
          Returns a set of keys, whose order is the order in which keys were added.
 ProjSettingsNode getNode(java.lang.String key)
           
 java.lang.String getPath()
          Returns a path to this ProjSettingsNode from the root.
 Setting getValue(java.lang.String key)
           
 boolean printDifferences(java.lang.Object node)
          Print any differences between the two nodes
protected  void put(java.lang.String key, java.lang.Object node)
           
 void putNode(java.lang.String key, ProjSettingsNode node)
           
 void putValue(java.lang.String key, Setting setting)
          Set the value for a key.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getPath

public java.lang.String getPath()
Returns a path to this ProjSettingsNode from the root. Keys in the path are separated by '.' char.

Returns:
path to this ProjSettingsNode from the root.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getKeys

public java.util.Set<java.lang.String> getKeys()
Returns a set of keys, whose order is the order in which keys were added.

Returns:
a set of keys in deterministic order

putValue

public void putValue(java.lang.String key,
                     Setting setting)
Set the value for a key.

Parameters:
key - a string key
setting - a value

getValue

public Setting getValue(java.lang.String key)

putNode

public void putNode(java.lang.String key,
                    ProjSettingsNode node)

getNode

public ProjSettingsNode getNode(java.lang.String key)

get

protected java.lang.Object get(java.lang.String key)

put

protected void put(java.lang.String key,
                   java.lang.Object node)

equal

public static boolean equal(java.lang.Object value,
                            Setting setting)
Compare a project settings value against a Setting object value. You can't just use .equals() because the Setting object does not store booleans as Booleans.

Parameters:
value -
setting -
Returns:
true if values equal, false otherwise

equals

public boolean equals(java.lang.Object node)
Overrides:
equals in class java.lang.Object

printDifferences

public boolean printDifferences(java.lang.Object node)
Print any differences between the two nodes

Parameters:
node - the nodes to compare
Returns:
true if differences found, false otherwise

describeContext

public static java.lang.String describeContext(java.util.Stack<java.lang.String> context)