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(NodeList control, NodeList test) { int numberOfControlNodes = control.getLength(); if (numberOfControlNodes != test.getLength()) { return false; } if(ignoreOrder){ for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(control.item(x), test)){ return false; } } for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(test.item(x), control)){ return false; } } }else{ for (int x = 0; x < numberOfControlNodes; x++) { if (!isNodeEqual(control.item(x), test.item(x))) { return false; } } } return true; }
private boolean isDocumentEqual(Document control, 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 isElementEqual(Element control, Element test) { if (!isStringEqual(control.getNamespaceURI(), test.getNamespaceURI())) { return false; if (!isStringEqual(control.getTagName(), test.getTagName())) { return false; } else if (!isAttributeEqual(controlAttribute, testAttribute)) { return false; return isNodeListEqual(control.getChildNodes(), test.getChildNodes());
private boolean isNodeInNodeList(Node node, NodeList nodeList){ int length = nodeList.getLength(); for (int x = 0; x < length; x++) { Node nextNode = nodeList.item(x); if(isNodeEqual(node, nextNode)){ return true; } } return false; }
public DirectToXMLTypeMapping() { super(); this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); this.xmlTransformer.setFormattedOutput(false); this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); this.xmlComparer = new XMLComparer(); }
private boolean isElementEqual(Element control, Element test) { if (!isStringEqual(control.getNamespaceURI(), test.getNamespaceURI())) { return false; if (!isStringEqual(control.getTagName(), test.getTagName())) { return false; } else if (!isAttributeEqual(controlAttribute, testAttribute)) { return false; return isNodeListEqual(control.getChildNodes(), test.getChildNodes());
private boolean isDocumentEqual(Document control, 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 isNodeInNodeList(Node node, NodeList nodeList){ int length = nodeList.getLength(); for (int x = 0; x < length; x++) { Node nextNode = nodeList.item(x); if(isNodeEqual(node, nextNode)){ return true; } } return false; }
public DirectToXMLTypeMapping() { super(); this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); this.xmlTransformer.setFormattedOutput(false); this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); this.xmlComparer = new XMLComparer(); }
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 isElementEqual(Element control, Element test) { if (!isStringEqual(control.getNamespaceURI(), test.getNamespaceURI())) { return false; if (!isStringEqual(control.getTagName(), test.getTagName())) { return false; } else if (!isAttributeEqual(controlAttribute, testAttribute)) { return false; return isNodeListEqual(control.getChildNodes(), test.getChildNodes());
private boolean isDocumentEqual(Document control, 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 isNodeListEqual(NodeList control, NodeList test) { int numberOfControlNodes = control.getLength(); if (numberOfControlNodes != test.getLength()) { return false; } if(ignoreOrder){ for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(control.item(x), test)){ return false; } } for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(test.item(x), control)){ return false; } } }else{ for (int x = 0; x < numberOfControlNodes; x++) { if (!isNodeEqual(control.item(x), test.item(x))) { return false; } } } return true; }
private boolean isNodeInNodeList(Node node, NodeList nodeList){ int length = nodeList.getLength(); for (int x = 0; x < length; x++) { Node nextNode = nodeList.item(x); if(isNodeEqual(node, nextNode)){ return true; } } return false; }
public DirectToXMLTypeMapping() { super(); this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); this.xmlTransformer.setFormattedOutput(false); this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); this.xmlComparer = new XMLComparer(); }
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(NodeList control, NodeList test) { int numberOfControlNodes = control.getLength(); if (numberOfControlNodes != test.getLength()) { return false; } if(ignoreOrder){ for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(control.item(x), test)){ return false; } } for (int x = 0; x < numberOfControlNodes; x++) { if(!isNodeInNodeList(test.item(x), control)){ return false; } } }else{ for (int x = 0; x < numberOfControlNodes; x++) { if (!isNodeEqual(control.item(x), test.item(x))) { return false; } } } return true; }
/** * INTERNAL: * Compare the attribute values. * Compare Nodes if mapped as a DOM. */ @Override protected boolean compareObjectValues(Object firstValue, Object secondValue, AbstractSession session) { // PERF: Check identity before conversion. if (firstValue == secondValue) { return true; } if ((firstValue == null) && (secondValue == null)) { return true; } if ((firstValue == null) || (secondValue == null)) { return false; } if (getAttributeClassification() == ClassConstants.STRING) { return firstValue.equals(secondValue); } else { Object one = getFieldValue(firstValue, session); Object two = getFieldValue(secondValue, session); if (one instanceof Node && two instanceof Node) { return this.xmlComparer.isNodeEqual((Node)one, (Node)two); } return one.equals(two); } } }
/** * INTERNAL: * Compare the attribute values. * Compare Nodes if mapped as a DOM. */ @Override protected boolean compareObjectValues(Object firstValue, Object secondValue, AbstractSession session) { // PERF: Check identity before conversion. if (firstValue == secondValue) { return true; } if ((firstValue == null) || (secondValue == null)) { return false; } if (getAttributeClassification() == ClassConstants.STRING) { return firstValue.equals(secondValue); } else { Object one = getFieldValue(firstValue, session); Object two = getFieldValue(secondValue, session); if (one instanceof Node && two instanceof Node) { return this.xmlComparer.isNodeEqual((Node)one, (Node)two); } return one.equals(two); } } }