for (int i = 0; i < numNode; i++) {
int extraChar = 0;
int orgDiffCount = diffCount;
TextNodeEntry orgTextNode = (TextNodeEntry)(orgNodeList.get(i));
Debug.log(Debug.INFO, "checking node " + (i + 1) + " of " + numNode);
// check any difference in this node and estimate the new char num
for (; diffCount < diffs.length; diffCount++) {
Debug.log(Debug.INFO, " checking diff " + (diffCount + 1) +
" of " + diffs.length);
Debug.log(Debug.INFO, " OrgPosision <" +
diffs[diffCount].getOrgPosition() + "> diffCount <" +
diffCount + "> orgDiffCount <" + orgDiffCount + ">");
// don't need to check and diffs beyond the current node text
// range except the last node
if (diffs[diffCount].getOrgPosition() > orgTextNode.endChar() &&
i < numNode - 1) {
Debug.log(Debug.INFO, " breaking!");
break;
}
if (diffs[diffCount].getOrgPosition()
>= orgTextNode.startChar()) {
if (diffs[diffCount].getOperation() == Difference.DELETE) {
extraChar--;
} else if (diffs[diffCount].getOperation()
== Difference.ADD) {
extraChar++;
}
}
}
Debug.log(Debug.INFO, " final diffCount <" + diffCount +
"> final orgDiffCount <" + orgDiffCount + ">");
// will only try to merge if there is a difference in this node
if (diffCount > orgDiffCount) {
Debug.log(Debug.INFO, " There is a difference, doing merge");
Debug.log(Debug.INFO, " TextNode name <" +
orgTextNode.node().getNodeName() + ">");
Debug.log(Debug.INFO, " TextNode value <" +
orgTextNode.node().getNodeValue() + ">");
Debug.log(Debug.INFO, " TextNode start char <" +
orgTextNode.startChar() + "> TextNode end char <" +
orgTextNode.endChar() + ">");
Debug.log(Debug.INFO, " extraChar value <" + extraChar + ">");
coreMerge(orgDiffCount, diffCount, diffs, orgParser,
modParser, orgTextNode, extraChar);
}