1 11 package org.eclipse.core.internal.dtree; 12 13 import org.eclipse.core.runtime.IPath; 14 15 22 public class NoDataDeltaNode extends AbstractDataTreeNode { 23 26 public NoDataDeltaNode(String name) { 27 this(name, NO_CHILDREN); 28 } 29 30 36 public NoDataDeltaNode(String name, AbstractDataTreeNode[] children) { 37 super(name, children); 38 } 39 40 46 NoDataDeltaNode(String localName, AbstractDataTreeNode childNode) { 47 super(localName, new AbstractDataTreeNode[] {childNode}); 48 } 49 50 53 AbstractDataTreeNode asBackwardDelta(DeltaDataTree myTree, DeltaDataTree parentTree, IPath key) { 54 int numChildren = children.length; 55 if (numChildren == 0) 56 return new NoDataDeltaNode(name, NO_CHILDREN); 57 AbstractDataTreeNode[] newChildren = new AbstractDataTreeNode[numChildren]; 58 for (int i = numChildren; --i >= 0;) { 59 newChildren[i] = children[i].asBackwardDelta(myTree, parentTree, key.append(children[i].getName())); 60 } 61 return new NoDataDeltaNode(name, newChildren); 62 } 63 64 67 AbstractDataTreeNode compareWithParent(IPath key, DeltaDataTree parent, IComparator comparator) { 68 AbstractDataTreeNode[] comparedChildren = compareWithParent(children, key, parent, comparator); 69 Object oldData = parent.getData(key); 70 return new DataTreeNode(key.lastSegment(), new NodeComparison(oldData, oldData, NodeComparison.K_CHANGED, 0), comparedChildren); 71 } 72 73 77 AbstractDataTreeNode copy() { 78 AbstractDataTreeNode[] childrenCopy; 79 if (children.length == 0) { 80 childrenCopy = NO_CHILDREN; 81 } else { 82 childrenCopy = new AbstractDataTreeNode[children.length]; 83 System.arraycopy(children, 0, childrenCopy, 0, children.length); 84 } 85 return new NoDataDeltaNode(name, childrenCopy); 86 } 87 88 92 boolean isDelta() { 93 return true; 94 } 95 96 99 boolean isEmptyDelta() { 100 return this.size() == 0; 101 } 102 103 106 AbstractDataTreeNode simplifyWithParent(IPath key, DeltaDataTree parent, IComparator comparer) { 107 AbstractDataTreeNode[] simplifiedChildren = simplifyWithParent(children, key, parent, comparer); 108 return new NoDataDeltaNode(name, simplifiedChildren); 109 } 110 111 115 public String toString() { 116 return "a NoDataDeltaNode(" + this.getName() + ") with " + getChildren().length + " children."; } 118 119 122 int type() { 123 return T_NO_DATA_DELTA_NODE; 124 } 125 } 126 | Popular Tags |