maspack.properties
Class PropTreeCell

java.lang.Object
  extended by maspack.properties.PropTreeCell

public class PropTreeCell
extends java.lang.Object

Container class for organizing property information into a tree.


Constructor Summary
PropTreeCell()
           
PropTreeCell(PropertyInfo info, java.lang.Object value)
           
PropTreeCell(PropTreeCell cell)
           
PropTreeCell(PropTreeData data)
           
 
Method Summary
 PropTreeCell addChild(PropertyInfo info, java.lang.Object value)
           
 void addChild(PropTreeCell child)
           
 void addChildren(PropTreeCell root)
          Adds the children of root to this cell.
 void addCopyOfChildrenAndData(PropTreeCell cell)
          Add to this node's children a copy of all the children (and their data objects) of cell.
 void addExplicitPropertyTree(HasProperties host)
          Recursively populates this cell with all the explicitly set inheritable properties accessible from a given host.
 void addLeafProperties(HasProperties host)
           
 void addNonexplicitPropertyTree(HasProperties host)
          Recursively populates this cell with all the non-explicitly set inheritable properties accessible from a given host.
 PropTreeCell copyChildren()
          Make a copy of this cell and it's first level of children that share's the same data cells as this cell.
 PropTreeCell copyTree()
          Returns a copy of the property tree whose root is this cell, while preserving the original data objects.
static PropTreeCell copyTree(PropTreeCell cell)
           
 PropTreeCell copyTreeAndData()
          Returns a complete copy of the property tree whose root is this cell, including copies of all data objects.
 PropTreeCell copyTreeChanges(PropTreeCell oldTree)
           
static PropTreeCell copyTreeUntil(PropTreeCell cell, PropTreeCell end)
           
 PropTreeCell createPathToRoot()
          Creates a new path of property cells from this cell all the way back to the root cell.
 void detachFromParent()
           
 PropTreeCell extendToHierarchyNode(HasProperties host)
          Extends this property tree all the way back to the hierarchy node associated with a particular host.
 java.lang.Object findInheritedValue(HierarchyNode node)
          Climbs a hierarchy to find the inherited value for the property path defined by this cell.
 PropTreeCell findMatchingChild(PropertyInfo info)
          Finds the child of this cell whose property matches the specified property information.
static PropertyInfo findMatchingProperty(HasProperties host, PropertyInfo info)
          Finds the property contained by a host that matches a specified property.
 PropTreeCell getChild(java.lang.String name)
           
 PropTreeCell getDescendant(java.lang.String path)
           
 java.lang.Object getExplicitValue(HasProperties host)
          Gets the explicit value, if possible, within a specfic host for the property path defined by this cell.
 PropTreeCell getFirstChild()
           
 int getIndex()
          Returns the index of this cell with respect to its parent, or -1 if it has no parent.
 int[] getIndexPath()
          Returns a path of indices that locate this cell starting from the root of the hierarchy.
 PropertyInfo getInfo()
           
 PropertyMode getMode()
           
 PropTreeCell getNext()
           
 PropTreeCell getParent()
           
 java.lang.Object getValue()
           
 boolean hasChildren()
           
 void inheritTreeValuesFromHierachy(HierarchyNode node)
          Climbs a hierarchy to determine all inherited values for the property tree defined by this cell.
 void inheritTreeValuesFromHost(HasProperties host)
          Sets cell values within this property tree from any explicitly-set matching properties in a specific host.
 int numChildren()
           
 int numLeafCells()
           
 java.lang.String pathString()
           
 void printTree(java.io.PrintStream ps)
           
 void removeAllChildren()
           
 void removeChild(PropTreeCell child)
           
 void removeDescendant(PropTreeCell cell)
           
 boolean removeDescendant(java.lang.String path)
           
 void setData(PropertyInfo info, java.lang.Object value)
           
 void setData(PropTreeData data)
           
 void setLeafValuesVoid()
           
 void setMode(PropertyMode mode)
           
 boolean setSingleEditDefaultValues()
          Rescursively descends this tree and, for any property whose editing property is Single, sets its value to the default value.
 void setTreeSingleEditDefaultValuesInHost(HasProperties dstHost, HasProperties srcHost)
          Uses the values contained with this property tree to set any matching properties within a specific destinate host.
 void setTreeValuesInHost(HasProperties dstHost, HasProperties srcHost)
          Uses the values contained with this property tree to set any matching properties within a specific destinate host.
 void setValue(java.lang.Object value)
           
 java.lang.String treeString()
           
 PropTreeCell updateTreeValuesInHost(HasProperties host, boolean reduce)
          Uses the values contained with this property tree to update any matching non-explicit properties within a specific host.
 void validate()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropTreeCell

public PropTreeCell(PropertyInfo info,
                    java.lang.Object value)

PropTreeCell

public PropTreeCell(PropTreeData data)

PropTreeCell

public PropTreeCell()

PropTreeCell

public PropTreeCell(PropTreeCell cell)
Method Detail

getMode

public PropertyMode getMode()

setMode

public void setMode(PropertyMode mode)

getValue

public java.lang.Object getValue()

setValue

public void setValue(java.lang.Object value)

getInfo

public PropertyInfo getInfo()

addChild

public PropTreeCell addChild(PropertyInfo info,
                             java.lang.Object value)

addChildren

public void addChildren(PropTreeCell root)
Adds the children of root to this cell. All children will be removed from root.


setData

public void setData(PropertyInfo info,
                    java.lang.Object value)

setData

public void setData(PropTreeData data)

addChild

public void addChild(PropTreeCell child)

hasChildren

public boolean hasChildren()

getFirstChild

public PropTreeCell getFirstChild()

getNext

public PropTreeCell getNext()

removeChild

public void removeChild(PropTreeCell child)

removeAllChildren

public void removeAllChildren()

setLeafValuesVoid

public void setLeafValuesVoid()

addCopyOfChildrenAndData

public void addCopyOfChildrenAndData(PropTreeCell cell)
Add to this node's children a copy of all the children (and their data objects) of cell.


copyChildren

public PropTreeCell copyChildren()
Make a copy of this cell and it's first level of children that share's the same data cells as this cell.


copyTree

public static PropTreeCell copyTree(PropTreeCell cell)

copyTree

public PropTreeCell copyTree()
Returns a copy of the property tree whose root is this cell, while preserving the original data objects.


copyTreeAndData

public PropTreeCell copyTreeAndData()
Returns a complete copy of the property tree whose root is this cell, including copies of all data objects.


copyTreeUntil

public static PropTreeCell copyTreeUntil(PropTreeCell cell,
                                         PropTreeCell end)

detachFromParent

public void detachFromParent()

printTree

public void printTree(java.io.PrintStream ps)

getChild

public PropTreeCell getChild(java.lang.String name)

getIndex

public int getIndex()
Returns the index of this cell with respect to its parent, or -1 if it has no parent.

Returns:
index of this cell

getIndexPath

public int[] getIndexPath()
Returns a path of indices that locate this cell starting from the root of the hierarchy.


getDescendant

public PropTreeCell getDescendant(java.lang.String path)

getParent

public PropTreeCell getParent()

removeDescendant

public boolean removeDescendant(java.lang.String path)

removeDescendant

public void removeDescendant(PropTreeCell cell)

numChildren

public int numChildren()

addLeafProperties

public void addLeafProperties(HasProperties host)

addExplicitPropertyTree

public void addExplicitPropertyTree(HasProperties host)
Recursively populates this cell with all the explicitly set inheritable properties accessible from a given host.

Parameters:
host - property host

extendToHierarchyNode

public PropTreeCell extendToHierarchyNode(HasProperties host)
Extends this property tree all the way back to the hierarchy node associated with a particular host. This is done by climbing the property tree back to the hierarchy node and prepending tree cells as required.

Parameters:
host - property host associated with the target hierarchy node
Returns:
new root cell for the extended property tree

createPathToRoot

public PropTreeCell createPathToRoot()
Creates a new path of property cells from this cell all the way back to the root cell. This is done by repeatedly getting a cell's parent until null is found. This routine is different from extendToHierarchyNode in that this cell is assumed to belong to an existing tree and therefore should not be modified.


addNonexplicitPropertyTree

public void addNonexplicitPropertyTree(HasProperties host)
Recursively populates this cell with all the non-explicitly set inheritable properties accessible from a given host.

Parameters:
host - property host

copyTreeChanges

public PropTreeCell copyTreeChanges(PropTreeCell oldTree)

findMatchingChild

public PropTreeCell findMatchingChild(PropertyInfo info)
Finds the child of this cell whose property matches the specified property information.


findMatchingProperty

public static PropertyInfo findMatchingProperty(HasProperties host,
                                                PropertyInfo info)
Finds the property contained by a host that matches a specified property.

Parameters:
host - property host in which to search
info - information for specified property
Returns:
information for matching property, if found

updateTreeValuesInHost

public PropTreeCell updateTreeValuesInHost(HasProperties host,
                                           boolean reduce)
Uses the values contained with this property tree to update any matching non-explicit properties within a specific host.

This method will also return a property tree which is suitable for propagation to descendant nodes within the hierarchy. The returned tree may be this tree or a modified copy of this tree. In particular, if reduce is true and the host contains matching non-explicit properties, then a copy of this tree is made with the associated property cells removed A returned value of null indicates an empty tree and implies that propagation should stop.

Parameters:
host - property host to update
reduce - if true, creates a copy of this tree with matching properties removed
Returns:
property tree for continuing the propagation further down the hierarchy

setTreeValuesInHost

public void setTreeValuesInHost(HasProperties dstHost,
                                HasProperties srcHost)
Uses the values contained with this property tree to set any matching properties within a specific destinate host.

If the tree contains any unexpanded composite properties, the source host is used to provide these instead.

Parameters:
dstHost - property host to update
srcHost - source for undefined property values

inheritTreeValuesFromHost

public void inheritTreeValuesFromHost(HasProperties host)
Sets cell values within this property tree from any explicitly-set matching properties in a specific host. The corresponding cells are then deleted.

Parameters:
host - property host

getExplicitValue

public java.lang.Object getExplicitValue(HasProperties host)
Gets the explicit value, if possible, within a specfic host for the property path defined by this cell.

Parameters:
host - property host
Returns:
explicit property value, or Property.VoidValue if the property is not found.

inheritTreeValuesFromHierachy

public void inheritTreeValuesFromHierachy(HierarchyNode node)
Climbs a hierarchy to determine all inherited values for the property tree defined by this cell.

Parameters:
node - base node whose ancestors are to supply the inheritance

findInheritedValue

public java.lang.Object findInheritedValue(HierarchyNode node)
Climbs a hierarchy to find the inherited value for the property path defined by this cell.

Parameters:
node - base node whose ancestors are to supply the inheritance

setSingleEditDefaultValues

public boolean setSingleEditDefaultValues()
Rescursively descends this tree and, for any property whose editing property is Single, sets its value to the default value. Returns true if any default values were set.


setTreeSingleEditDefaultValuesInHost

public void setTreeSingleEditDefaultValuesInHost(HasProperties dstHost,
                                                 HasProperties srcHost)
Uses the values contained with this property tree to set any matching properties within a specific destinate host.

If the tree contains any unexpanded composite properties, the source host is used to provide these instead.

Parameters:
dstHost - property host to update
srcHost - source for undefined property values

numLeafCells

public int numLeafCells()

treeString

public java.lang.String treeString()

pathString

public java.lang.String pathString()

validate

public void validate()