Methods Summary |
---|
private boolean | isAttributeEqual(org.w3c.dom.Attr control, org.w3c.dom.Attr test)
if (!isStringEqual(control.getNamespaceURI(), test.getNamespaceURI())) {
return false;
}
if (!isStringEqual(control.getName(), test.getName())) {
return false;
}
if (!isStringEqual(control.getNodeValue(), test.getNodeValue())) {
return false;
}
return true;
|
private boolean | isCommentEqual(org.w3c.dom.Comment control, org.w3c.dom.Comment test)
if (!isStringEqual(control.getNodeValue(), test.getNodeValue())) {
return false;
}
return true;
|
private boolean | isDocumentEqual(org.w3c.dom.Document control, org.w3c.dom.Document test)
if (!isDocumentTypeEqual(control.getDoctype(), test.getDoctype())) {
return false;
}
Element controlRootElement = control.getDocumentElement();
Element testRootElement = test.getDocumentElement();
if (controlRootElement == testRootElement) {
return true;
} else if ((null == controlRootElement) || (null == testRootElement)) {
return false;
}
return isElementEqual(controlRootElement, testRootElement);
|
private boolean | isDocumentFragmentEqual(org.w3c.dom.DocumentFragment control, org.w3c.dom.DocumentFragment test)
return isNodeListEqual(control.getChildNodes(), test.getChildNodes());
|
private boolean | isDocumentTypeEqual(org.w3c.dom.DocumentType control, org.w3c.dom.DocumentType test)
if (control == test) {
return true;
} else if ((null == control) || (null == test)) {
return false;
}
if (!isStringEqual(control.getName(), test.getName())) {
return false;
}
if (!isStringEqual(control.getPublicId(), test.getPublicId())) {
return false;
}
if (!isStringEqual(control.getSystemId(), test.getSystemId())) {
return false;
}
return true;
|
private boolean | isElementEqual(org.w3c.dom.Element control, org.w3c.dom.Element test)
if (!isStringEqual(control.getNamespaceURI(), test.getNamespaceURI())) {
return false;
}
if (!isStringEqual(control.getTagName(), test.getTagName())) {
return false;
}
// COMPARE ATTRIBUTES
NamedNodeMap controlAttributes = control.getAttributes();
NamedNodeMap testAttributes = test.getAttributes();
int numberOfControlAttributes = controlAttributes.getLength();
if (numberOfControlAttributes != testAttributes.getLength()) {
return false;
}
Attr controlAttribute;
Attr testAttribute;
for (int x = 0; x < numberOfControlAttributes; x++) {
controlAttribute = (Attr)controlAttributes.item(x);
if (null == controlAttribute.getNamespaceURI()) {
testAttribute = (Attr)testAttributes.getNamedItem(controlAttribute.getNodeName());
} else {
testAttribute = (Attr)testAttributes.getNamedItemNS(controlAttribute.getNamespaceURI(), controlAttribute.getLocalName());
}
if (null == testAttribute) {
return false;
} else if (!isAttributeEqual(controlAttribute, testAttribute)) {
return false;
}
}
// COMPARE CHILD NODES
return isNodeListEqual(control.getChildNodes(), test.getChildNodes());
|
private boolean | isEntityReferenceEqual(org.w3c.dom.EntityReference control, org.w3c.dom.EntityReference test)
if (!isStringEqual(control.getNodeName(), test.getNodeName())) {
return false;
}
return true;
|
public boolean | isNodeEqual(org.w3c.dom.Node control, org.w3c.dom.Node test)Compare two DOM nodes.
if (control == test) {
return true;
} else if ((null == control) || (null == test)) {
return false;
} else if (control.getNodeType() != test.getNodeType()) {
return false;
}
switch (control.getNodeType()) {
case (Node.ATTRIBUTE_NODE):
return isAttributeEqual((Attr)control, (Attr)test);
case (Node.CDATA_SECTION_NODE):
return isTextEqual((Text)control, (Text)test);
case (Node.COMMENT_NODE):
return isCommentEqual((Comment)control, (Comment)test);
case (Node.DOCUMENT_FRAGMENT_NODE):
return isDocumentFragmentEqual((DocumentFragment)control, (DocumentFragment)test);
case (Node.DOCUMENT_NODE):
return isDocumentEqual((Document)control, (Document)test);
case (Node.DOCUMENT_TYPE_NODE):
return isDocumentTypeEqual((DocumentType)control, (DocumentType)test);
case (Node.ELEMENT_NODE):
return isElementEqual((Element)control, (Element)test);
case (Node.ENTITY_NODE):
return false;
case (Node.ENTITY_REFERENCE_NODE):
return isEntityReferenceEqual((EntityReference)control, (EntityReference)test);
case (Node.NOTATION_NODE):
return false;
case (Node.PROCESSING_INSTRUCTION_NODE):
return isProcessingInstructionEqual((ProcessingInstruction)control, (ProcessingInstruction)test);
case (Node.TEXT_NODE):
return isTextEqual((Text)control, (Text)test);
default:
return true;
}
|
private boolean | isNodeListEqual(org.w3c.dom.NodeList control, org.w3c.dom.NodeList test)
int numberOfControlNodes = control.getLength();
if (numberOfControlNodes != test.getLength()) {
return false;
}
for (int x = 0; x < numberOfControlNodes; x++) {
if (!isNodeEqual(control.item(x), test.item(x))) {
return false;
}
}
return true;
|
private boolean | isProcessingInstructionEqual(org.w3c.dom.ProcessingInstruction control, org.w3c.dom.ProcessingInstruction test)
if (!isStringEqual(control.getTarget(), test.getTarget())) {
return false;
}
if (!isStringEqual(control.getData(), test.getData())) {
return false;
}
return true;
|
private boolean | isStringEqual(java.lang.String control, java.lang.String test)
if (control == test) {
return true;
} else if (null == control) {
return false;
} else {
return control.equals(test);
}
|
private boolean | isTextEqual(org.w3c.dom.Text control, org.w3c.dom.Text test)
return isStringEqual(control.getNodeValue(), test.getNodeValue());
|