|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.internal.dtree.AbstractDataTree
org.eclipse.core.internal.dtree.DeltaDataTree
public class DeltaDataTree
Externally, a DeltaDataTree
appears to have the same content as
a standard data tree. Internally, the delta tree may be complete, or it may
just indicate the changes between itself and its parent.
Nodes that exist in the parent but do not exist in the delta, are represented
as instances of DeletedNode
. Nodes that are identical in the parent
and the delta, but have differences in their subtrees, are represented as
instances of NoDataDeltaNode
in the delta tree. Nodes that differ
between parent and delta are instances of DataDeltaNode
. However,
the DataDeltaNode
only contains the children whose subtrees differ
between parent and delta.
A delta tree algebra is used to manipulate sets of delta trees. Given two trees,
one can obtain the delta between the two using the method
forwardDeltaWith(aTree)
. Given a tree and a delta, one can assemble
the complete tree that the delta represents using the method
assembleWithForwardDelta
. Refer to the public API methods of this class
for further details.
Constructor Summary | |
---|---|
DeltaDataTree()
Creates a new empty tree. |
|
DeltaDataTree(AbstractDataTreeNode rootNode)
Creates a new tree. |
Method Summary | |
---|---|
DeltaDataTree |
asReverseComparisonTree(IComparator comparator)
This method can only be called on a comparison tree created using DeltaDataTree.compareWith(). |
DeltaDataTree |
assembleWithForwardDelta(DeltaDataTree deltaTree)
Assembles the receiver with the given delta tree and answer the resulting, mutable source tree. |
DeltaDataTree |
collapseTo(DeltaDataTree collapseTo,
IComparator comparator)
Collapses this tree so that the given ancestor becomes its immediate parent. |
DeltaDataTree |
compareWith(DeltaDataTree other,
IComparator comparator)
Returns a DeltaDataTree that describes the differences between this tree and "other" tree. |
DeltaDataTree |
compareWith(DeltaDataTree other,
IComparator comparator,
org.eclipse.core.runtime.IPath path)
Compares this tree with another tree, starting from the given path. |
AbstractDataTreeNode |
copyCompleteSubtree(org.eclipse.core.runtime.IPath key)
Returns a complete node containing the contents of a subtree of the tree. |
void |
createChild(org.eclipse.core.runtime.IPath parentKey,
java.lang.String localName)
Creates a new child in the tree. |
void |
createChild(org.eclipse.core.runtime.IPath parentKey,
java.lang.String localName,
java.lang.Object data)
Creates a new child in the tree. |
void |
createSubtree(org.eclipse.core.runtime.IPath key,
AbstractDataTreeNode node)
Creates or replaces a subtree in the tree. |
void |
deleteChild(org.eclipse.core.runtime.IPath parentKey,
java.lang.String localName)
Deletes a child from the tree. |
void |
empty()
Initializes the receiver so that it is a complete, empty tree. |
AbstractDataTreeNode |
findNodeAt(org.eclipse.core.runtime.IPath key)
Returns a node of the tree if it is present, otherwise returns null |
DeltaDataTree |
forwardDeltaWith(DeltaDataTree sourceTree,
IComparator comparer)
Returns a forward delta between the receiver and the given source tree, using the given comparer to compare data objects. |
int |
getChildCount(org.eclipse.core.runtime.IPath parentKey)
Returns the number of children of a node |
org.eclipse.core.runtime.IPath[] |
getChildren(org.eclipse.core.runtime.IPath parentKey)
Returns the keys of all children of a node. |
java.lang.Object |
getData(org.eclipse.core.runtime.IPath key)
Returns the data at a node of the tree. |
java.lang.String |
getNameOfChild(org.eclipse.core.runtime.IPath parentKey,
int index)
Returns the local name of a node in the tree |
java.lang.String[] |
getNamesOfChildren(org.eclipse.core.runtime.IPath parentKey)
Returns the local names for the children of a node of the tree. |
DeltaDataTree |
getParent()
Returns the parent of the tree. |
boolean |
includes(org.eclipse.core.runtime.IPath key)
Returns true if the receiver includes a node with the given key, false otherwise. |
boolean |
isEmptyDelta()
|
DataTreeLookup |
lookup(org.eclipse.core.runtime.IPath key)
Returns an object containing: - the node key - a flag indicating whether the specified node was found - the data for the node, if it was found |
DataTreeLookup |
lookupIgnoreCase(org.eclipse.core.runtime.IPath key)
Returns an object containing: - the node key - a flag indicating whether the specified node was found - the data for the node, if it was found This is a case-insensitive variant of the lookup
method. |
void |
makeComplete()
Converts this tree's representation to be a complete tree, not a delta. |
DeltaDataTree |
newEmptyDeltaTree()
Returns a new tree which represents an empty, mutable delta on the receiver. |
DeltaDataTree |
reroot()
Makes the receiver the root tree in the list of trees on which it is based. |
AbstractDataTreeNode |
safeCopyCompleteSubtree(org.eclipse.core.runtime.IPath key)
Returns a complete node containing the contents of a subtree of the tree. |
void |
setData(org.eclipse.core.runtime.IPath key,
java.lang.Object data)
Sets the data of a node. |
void |
storeStrings(StringPool set)
|
Methods inherited from class org.eclipse.core.internal.dtree.AbstractDataTree |
---|
getChild, immutable, isImmutable, rootKey |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeltaDataTree()
public DeltaDataTree(AbstractDataTreeNode rootNode)
rootNode
- root node of new tree.Method Detail |
---|
public DeltaDataTree asReverseComparisonTree(IComparator comparator)
public DeltaDataTree assembleWithForwardDelta(DeltaDataTree deltaTree)
In detail, suppose that c is a forward delta over source tree a. Let d := a assembleWithForwardDelta: c. d has the same content as c, and is represented as a delta tree whose parent is the same as a's parent.
In general, if c is represented as a chain of deltas of length n, then d is represented as a chain of length n-1.
So if a is a complete tree (i.e., has no parent, length=0), then d will be a complete tree too.
Corollary: (a assembleWithForwardDelta: (a forwardDeltaWith: b)) = b
public DeltaDataTree collapseTo(DeltaDataTree collapseTo, IComparator comparator)
This operation should be used to collapse chains of delta trees that don't contain interesting intermediate states.
This is a destructive operation, since it modifies the structure of this tree instance. This tree must be immutable at the start of this operation, and will be immutable afterwards.
public DeltaDataTree compareWith(DeltaDataTree other, IComparator comparator)
public DeltaDataTree compareWith(DeltaDataTree other, IComparator comparator, org.eclipse.core.runtime.IPath path)
public AbstractDataTreeNode copyCompleteSubtree(org.eclipse.core.runtime.IPath key)
copyCompleteSubtree
in class AbstractDataTree
key
- key of subtree to copypublic void createChild(org.eclipse.core.runtime.IPath parentKey, java.lang.String localName)
AbstractDataTree
createChild
in class AbstractDataTree
parentKey
- key of parent for new child.localName
- name for new child.AbstractDataTree.createChild(IPath, String)
public void createChild(org.eclipse.core.runtime.IPath parentKey, java.lang.String localName, java.lang.Object data)
AbstractDataTree
createChild
in class AbstractDataTree
parentKey
- key of parent for new child.localName
- name for new child.data
- the data for the new childAbstractDataTree.createChild(IPath, String, Object)
public void createSubtree(org.eclipse.core.runtime.IPath key, AbstractDataTreeNode node)
AbstractDataTree
createSubtree
in class AbstractDataTree
key
- key of parent of subtree to create/replacenode
- new subtree to add to treeAbstractDataTree.createSubtree(IPath, AbstractDataTreeNode)
public void deleteChild(org.eclipse.core.runtime.IPath parentKey, java.lang.String localName)
AbstractDataTree
Note: this method requires both parentKey and localName, making it impossible to delete the root node.
deleteChild
in class AbstractDataTree
parentKey
- parent of node to delete.localName
- name of node to delete.AbstractDataTree.deleteChild(IPath, String)
public void empty()
empty
in class AbstractDataTree
AbstractDataTree.empty()
public AbstractDataTreeNode findNodeAt(org.eclipse.core.runtime.IPath key)
key
- key of node to findpublic DeltaDataTree forwardDeltaWith(DeltaDataTree sourceTree, IComparator comparer)
sourceTree
- second delta tree to create a delta betweencomparer
- the comparer used to compare data objects
public int getChildCount(org.eclipse.core.runtime.IPath parentKey)
AbstractDataTree
getChildCount
in class AbstractDataTree
parentKey
- key of the node for which we want to retreive the number of childrenAbstractDataTree.getChildCount(IPath)
public org.eclipse.core.runtime.IPath[] getChildren(org.eclipse.core.runtime.IPath parentKey)
AbstractDataTree
getChildren
in class AbstractDataTree
parentKey
- key of parent whose children we want to retrieve.AbstractDataTree.getChildren(IPath)
public java.lang.Object getData(org.eclipse.core.runtime.IPath key)
getData
in class AbstractDataTree
key
- key of node for which to return data.public java.lang.String getNameOfChild(org.eclipse.core.runtime.IPath parentKey, int index)
AbstractDataTree
getNameOfChild
in class AbstractDataTree
parentKey
- parent of node whose name we want to retrieveindex
- index of node in its parentAbstractDataTree.getNameOfChild(IPath, int)
public java.lang.String[] getNamesOfChildren(org.eclipse.core.runtime.IPath parentKey)
getNamesOfChildren
in class AbstractDataTree
parentKey
- key of node whose children we want to retrieveAbstractDataTree.getNamesOfChildren(IPath)
public DeltaDataTree getParent()
public boolean includes(org.eclipse.core.runtime.IPath key)
includes
in class AbstractDataTree
key
- key of node to findpublic boolean isEmptyDelta()
public DataTreeLookup lookup(org.eclipse.core.runtime.IPath key)
lookup
in class AbstractDataTree
key
- key of node for which we want to retrieve data.public DataTreeLookup lookupIgnoreCase(org.eclipse.core.runtime.IPath key)
lookup
method.
key
- key of node for which we want to retrieve data.public void makeComplete()
public DeltaDataTree newEmptyDeltaTree()
public DeltaDataTree reroot()
java.lang.RuntimeException
- receiver is not immutablepublic AbstractDataTreeNode safeCopyCompleteSubtree(org.eclipse.core.runtime.IPath key)
key
- key of subtree to copypublic void setData(org.eclipse.core.runtime.IPath key, java.lang.Object data)
AbstractDataTree
setData
in class AbstractDataTree
key
- key of node for which to set datadata
- new data value for nodeAbstractDataTree.setData(IPath, Object)
public void storeStrings(StringPool set)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |