19package org.openoffice.xmerge.merger.diff;
21import java.util.ArrayList;
28import org.w3c.dom.NamedNodeMap;
29import org.w3c.dom.Node;
30import org.w3c.dom.NodeList;
99 if (currentPosition < 0 || currentPosition >=
nodeList.size()) {
110 boolean equal =
false;
111 if (!(obj1 instanceof Node && obj2 instanceof Node)) {
115 Node node1 = (Node)obj1;
116 Node node2 = (Node)obj2;
139 boolean equal =
false;
143 if (node1 ==
null || node2 ==
null) {
148 if (node1.getNodeType() != node2.getNodeType()) {
153 if (!node1.getNodeName().equals(node2.getNodeName())) {
158 if (node1.getNodeValue() ==
null && node2.getNodeValue() ==
null) {
160 }
else if (node1.getNodeValue() ==
null ||
161 node2.getNodeValue() ==
null) {
163 }
else if (!node1.getNodeValue().equals(node2.getNodeValue())) {
173 if (!node1.hasChildNodes() && !node2.hasChildNodes()) {
177 }
else if (!node1.hasChildNodes() || !node2.hasChildNodes()) {
205 boolean equal =
false;
208 NodeList node1Children = node1.getChildNodes();
209 NodeList node2Children = node2.getChildNodes();
211 if (node1Children ==
null || node2Children ==
null) {
215 if (node1Children.getLength() != node2Children.getLength()) {
222 for (
int i = 0;
i < node1Children.getLength();
i++) {
224 node2Children.item(
i))) {
248 boolean equal =
false;
249 String nodeName = node1.getNodeName();
250 NamedNodeMap attrNode[] =
new NamedNodeMap[2];
251 attrNode[0] = node1.getAttributes();
252 attrNode[1] = node2.getAttributes();
256 if (attrNode[0] ==
null || attrNode[1] ==
null) {
257 if (attrNode[0] ==
null && attrNode[1] ==
null) {
267 int len [] =
new int[2];
271 for (
int i = 0;
i < 2;
i++) {
281 len[src] = attrNode[src].getLength();
283 for (
int j = 0; j < len[src]; j++) {
284 Node srcAttr = attrNode[src].item(j);
285 String srcAttrName = srcAttr.getNodeName();
292 Node dstAttr = attrNode[dst].getNamedItem(srcAttrName);
294 if (dstAttr ==
null) {
296 "[NodeIterator] Attr not exist in dst - "
302 if (!srcAttr.getNodeValue().equals(
303 dstAttr.getNodeValue())) {
305 "[NodeIterator] Attr diff src: " +
306 srcAttr.getNodeValue() +
" dst: "+
307 dstAttr.getNodeValue());
344 String nodeName = node.getNodeName();
346 NodeList auxNodeList = node.getChildNodes();
347 int nodeListLength = auxNodeList.getLength();
348 for (
int i = 0;
i < nodeListLength;
i++) {
This is an implementation of the Iterator interface.
boolean compareNode(Node node1, Node node2)
Used to compare two Node objects (type/name/value) and all their children Node objects.
boolean childrenEqual(Node node1, Node node2)
Compare the children of two Node objects.
boolean equivalent(Object obj1, Object obj2)
A method to allow the difference algorithm to test whether the obj1 and obj2 in the Iterator are cons...
abstract boolean nodeSupported(Node node)
Check whether a Node is supported.
final ConverterCapabilities cc_
Object start()
Move to the beginning of the sequence.
boolean attributesEqual(Node node1, Node node2)
Compare attributes of two Node objects.
void refresh()
A method to force the Iterator to traverse the tree again to refresh the content.
Object currentElement()
Return the current element Object content.
Object next()
Move to next element in the sequence.
int elementCount()
Return the total element count in the sequence.
NodeIterator(ConverterCapabilities cc, Node node)
Standard constructor.
This class is used for logging debug messages.
static final int INFO
Informational messages.
static void log(int flag, String msg)
Log message based on the flag type.
static final int ERROR
Error messages.
Provides a singleton resource class for converter messages.
static synchronized Resources getInstance()
This method returns the singleton instance of this class.
String getString(String key)
This method returns the corresponding String given the key.
A ConverterCapabilities object is used by DocumentMerger implementations.
boolean canConvertAttribute(String tag, String attribute)
Test to see if the device document format supports the tag attribute in question.
boolean canConvertTag(String tag)
Test to see if the device document format supports the tag in question.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
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...