19package org.openoffice.xmerge.merger.merge;
21import org.w3c.dom.Element;
22import org.w3c.dom.Node;
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()) {
157 (Element)modSeq.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);
This Exception is thrown by merge algorithms.
This is the Difference basic unit.
static final int CHANGE
Change operation.
static final int DELETE
Delete operation.
static final int ADD
Add operation.
This is an implementation of the MergeAlgorithm interface.
void insertNode(Node oldNode, Node newNode)
Insert Node before the specified Node.
ConverterCapabilities cc_
The capabilities of this converter.
void appendNode(Node oldNode, Node newNode)
Appends Node after the specified Node.
void removeNode(Node node)
Removes the specified Node.
void replaceElement(Element currElem, Element newElem)
Replace Element.
void applyDifference(Iterator orgSeq, Iterator modSeq, Difference[] differences)
This method is to merge the difference to an Iterator.
DocumentMerge(ConverterCapabilities cc, NodeMergeAlgorithm merge)
Constructor.
final NodeMergeAlgorithm subDocumentMerge
Class containing static utility methods for handling XML trees.
static Node deepClone(Node oldNode, Node newNode)
Perform a deep clone of certain Node which will base on the document Node of the old Node.
A ConverterCapabilities object is used by DocumentMerger implementations.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
This is the MergeAlgorithm interface.
This is an interface for a MergeAlgorithm to merge two Node objects.
void merge(Node originalNode, Node modifyNode)
This method is used to merge two given Node objects.
The DiffAlgorithm and MergeAlgorithm are used to provide the merge capabilities of this project.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...