1 19 20 package org.netbeans.modules.xml.xdm.diff; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import org.netbeans.modules.xml.xdm.nodes.Document; 25 import org.netbeans.modules.xml.xdm.nodes.Node; 26 27 32 public abstract class Difference { 33 34 35 public Difference(NodeInfo.NodeType nodeType, 36 List <Node> ancestors1, List <Node> ancestors2, 37 Node n1, Node n2, int n1Pos, int n2Pos) { 38 this.nodeType = nodeType; 39 if (! (n1 instanceof Document)) { 40 assert ancestors1 != null && ! ancestors1.isEmpty() : "diff of non-root should have ancestors"; 41 } 42 this.oldNodeInfo = new NodeInfo( n1, n1Pos, ancestors1, ancestors2); 43 this.newNodeInfo = new NodeInfo( n2, n2Pos, new ArrayList (ancestors1), new ArrayList (ancestors2)); 44 if (newNodeInfo.getNode() != null && newNodeInfo.getNewAncestors().size() > 0) { 45 assert newNodeInfo.getNewAncestors().get(0).getId() != newNodeInfo.getNode().getId(); 46 } 47 } 48 49 public NodeInfo.NodeType getNodeType() { 50 return nodeType; 51 } 52 53 56 public NodeInfo getOldNodeInfo() { 57 return oldNodeInfo; 58 } 59 60 63 public NodeInfo getNewNodeInfo() { 64 return newNodeInfo; 65 } 66 67 70 public abstract List <Node> getNewAncestors(); 71 72 public abstract void setNewParent(Node n); 73 74 public abstract Node getNewParent(); 75 76 80 private NodeInfo.NodeType nodeType; 81 82 private NodeInfo oldNodeInfo; 83 84 private NodeInfo newNodeInfo; 85 86 } 87 | Popular Tags |