19 package org.openoffice.xmerge.merger.merge;
21 import org.w3c.dom.Element;
22 import org.w3c.dom.Node;
55 subDocumentMerge = merge;
62 int currentPosition = -1;
63 boolean haveDeleteOperation =
false;
66 if (difference.getOrgPosition() > currentPosition) {
67 currentPosition = difference.getOrgPosition();
69 }
else if (difference.getOrgPosition() == currentPosition) {
71 haveDeleteOperation =
true;
73 haveDeleteOperation) {
75 "Differences array is not sorted. Delete before Add");
84 int orgSeqCounter = 0;
87 int modSeqCounter = 0;
92 int operation = currentDiff.getOperation();
101 orgSeqCounter < currentDiff.getOrgPosition();
102 orgSeqCounter++, orgSeq.next()) {
118 modSeqCounter < currentDiff.getModPosition();
119 modSeqCounter++, modSeq.next()) {
124 orgSeqCounter < currentDiff.getOrgPosition();
125 orgSeqCounter++, orgSeq.next()) {
129 if (orgSeqCounter > orgSeq.elementCount() - 1) {
132 (Node)(modSeq.currentElement()));
136 (Node)(modSeq.currentElement()));
143 modSeqCounter < currentDiff.getModPosition();
144 modSeqCounter++, modSeq.next()) {
149 orgSeqCounter < currentDiff.getOrgPosition();
150 orgSeqCounter++, orgSeq.next()) {
154 if (subDocumentMerge == null) {
157 (Element)modSeq.currentElement());
159 subDocumentMerge.
merge((Element)orgSeq.currentElement(),
160 (Element)modSeq.currentElement());
178 Node parent = node.getParentNode();
179 parent.removeChild(node);
190 Node parent = oldNode.getParentNode();
191 parent.appendChild(clonedNode);
202 Node parent = oldNode.getParentNode();
203 parent.insertBefore(clonedNode, oldNode);
215 Node parent = currElem.getParentNode();
216 parent.replaceChild(clonedNode, currElem);
static Node deepClone(Node oldNode, Node newNode)
Perform a deep clone of certain.
Provides general purpose utilities.
static final int DELETE
Delete operation.
This is an implementation of the.
void insertNode(Node oldNode, Node newNode)
Insert.
DocumentMerge(ConverterCapabilities cc, NodeMergeAlgorithm merge)
Constructor.
void replaceElement(Element currElem, Element newElem)
Replace Element.
static final int CHANGE
Change operation.
final NodeMergeAlgorithm subDocumentMerge
Class containing static utility methods for handling XML trees.
void removeNode(Node node)
Removes the specified.
ConverterCapabilities cc_
The capabilities of this converter.
void applyDifference(Iterator orgSeq, Iterator modSeq, Difference[] differences)
This method is to merge the difference to an.
void appendNode(Node oldNode, Node newNode)
Appends.
This is an interface for a MergeAlgorithm to merge two.
Provides interfaces for converting between two.
static final int ADD
Add operation.
void merge(Node originalNode, Node modifyNode)
This method is used to merge two given.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a.