/**
* Reads an element tree delta from the input stream, and
* reconstructs it as a delta on the given tree.
*/
public ElementTree readDelta(ElementTree parentTree, DataInput input) throws IOException {
DeltaDataTree complete = parentTree.getDataTree();
DeltaDataTree delta = dataTreeReader.readTree(complete, input);
//if the delta is empty, just return the parent
if (delta.isEmptyDelta())
return parentTree;
ElementTree tree = new ElementTree(delta);
//copy the user data forward
IElementTreeData data = parentTree.getTreeData();
if (data != null) {
tree.setTreeData((IElementTreeData) data.clone());
}
//make the underlying data tree immutable
//can't call immutable() on the ElementTree because
//this would attempt to reroot.
delta.immutable();
return tree;
}