Compare 2 elements and their attributes
@param control
@param test
@param listener
@throws DifferenceFoundException
421544
protected void compareElement(Element control, Element test,
                                  DifferenceListener listener) throws DifferenceFoundException {
        compare(getUnNamespacedNodeName(control), getUnNamespacedNodeName(test), 
                control, test, listener, ELEMENT_TAG_NAME);

        NamedNodeMap controlAttr = control.getAttributes();
        Integer controlNonXmlnsAttrLength =
            getNonSpecialAttrLength(controlAttr);
        NamedNodeMap testAttr = test.getAttributes();
        Integer testNonXmlnsAttrLength = getNonSpecialAttrLength(testAttr);
        compare(controlNonXmlnsAttrLength, testNonXmlnsAttrLength,
                control, test, listener, ELEMENT_NUM_ATTRIBUTES);

        compareElementAttributes(control, test, controlAttr, testAttr,
                                 listener);
    }
392271
final public void Compare() throws ParseException {
    Concatenation();
    label_10:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case GT0:
      case GT1:
      case LT0:
      case LT1:
      case GE0:
      case GE1:
      case LE0:
      case LE1:
        ;
        break;
      default:
        jj_la1[18] = jj_gen;
        break label_10;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LT0:
      case LT1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LT0:
          jj_consume_token(LT0);
          break;
        case LT1:
          jj_consume_token(LT1);
          break;
        default:
          jj_la1[19] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                         AstLessThan jjtn001 = new AstLessThan(JJTLESSTHAN);
                         boolean jjtc001 = true;
                         jjtree.openNodeScope(jjtn001);
        try {
          Concatenation();
        } catch (Throwable jjte001) {
                         if (jjtc001) {
                           jjtree.clearNodeScope(jjtn001);
                           jjtc001 = false;
                         } else {
                           jjtree.popNode();
                         }
                         if (jjte001 instanceof RuntimeException) {
                           {if (true) throw (RuntimeException)jjte001;}
                         }
                         if (jjte001 instanceof ParseException) {
                           {if (true) throw (ParseException)jjte001;}
                         }
                         {if (true) throw (Error)jjte001;}
        } finally {
                         if (jjtc001) {
                           jjtree.closeNodeScope(jjtn001,  2);
                         }
        }
        break;
      case GT0:
      case GT1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case GT0:
          jj_consume_token(GT0);
          break;
        case GT1:
          jj_consume_token(GT1);
          break;
        default:
          jj_la1[20] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                         AstGreaterThan jjtn002 = new AstGreaterThan(JJTGREATERTHAN);
                         boolean jjtc002 = true;
                         jjtree.openNodeScope(jjtn002);
        try {
          Concatenation();
        } catch (Throwable jjte002) {
                         if (jjtc002) {
                           jjtree.clearNodeScope(jjtn002);
                           jjtc002 = false;
                         } else {
                           jjtree.popNode();
                         }
                         if (jjte002 instanceof RuntimeException) {
                           {if (true) throw (RuntimeException)jjte002;}
                         }
                         if (jjte002 instanceof ParseException) {
                           {if (true) throw (ParseException)jjte002;}
                         }
                         {if (true) throw (Error)jjte002;}
        } finally {
                         if (jjtc002) {
                           jjtree.closeNodeScope(jjtn002,  2);
                         }
        }
        break;
      case LE0:
      case LE1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LE0:
          jj_consume_token(LE0);
          break;
        case LE1:
          jj_consume_token(LE1);
          break;
        default:
          jj_la1[21] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                         AstLessThanEqual jjtn003 = new AstLessThanEqual(JJTLESSTHANEQUAL);
                         boolean jjtc003 = true;
                         jjtree.openNodeScope(jjtn003);
        try {
          Concatenation();
        } catch (Throwable jjte003) {
                         if (jjtc003) {
                           jjtree.clearNodeScope(jjtn003);
                           jjtc003 = false;
                         } else {
                           jjtree.popNode();
                         }
                         if (jjte003 instanceof RuntimeException) {
                           {if (true) throw (RuntimeException)jjte003;}
                         }
                         if (jjte003 instanceof ParseException) {
                           {if (true) throw (ParseException)jjte003;}
                         }
                         {if (true) throw (Error)jjte003;}
        } finally {
                         if (jjtc003) {
                           jjtree.closeNodeScope(jjtn003,  2);
                         }
        }
        break;
      case GE0:
      case GE1:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case GE0:
          jj_consume_token(GE0);
          break;
        case GE1:
          jj_consume_token(GE1);
          break;
        default:
          jj_la1[22] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
                         AstGreaterThanEqual jjtn004 = new AstGreaterThanEqual(JJTGREATERTHANEQUAL);
                         boolean jjtc004 = true;
                         jjtree.openNodeScope(jjtn004);
        try {
          Concatenation();
        } catch (Throwable jjte004) {
                         if (jjtc004) {
                           jjtree.clearNodeScope(jjtn004);
                           jjtc004 = false;
                         } else {
                           jjtree.popNode();
                         }
                         if (jjte004 instanceof RuntimeException) {
                           {if (true) throw (RuntimeException)jjte004;}
                         }
                         if (jjte004 instanceof ParseException) {
                           {if (true) throw (ParseException)jjte004;}
                         }
                         {if (true) throw (Error)jjte004;}
        } finally {
                         if (jjtc004) {
                           jjtree.closeNodeScope(jjtn004,  2);
                         }
        }
        break;
      default:
        jj_la1[23] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  }
926682
public void tryCompare() throws CmsException {

        CmsObject cms = A_CmsUI.getCmsObject();
        CheckBox check1 = m_group1.getSelected();
        CheckBox check2 = m_group2.getSelected();
        if (!canCompare(check1, check2)) {
            Notification.show(
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_SELECT_TWO_DIFFERENT_VERSIONS_0));
        } else {
            CmsHistoryResourceBean bean1 = (CmsHistoryResourceBean)(check1.getData());
            CmsHistoryResourceBean bean2 = (CmsHistoryResourceBean)(check2.getData());
            VerticalLayout diffContainer = new VerticalLayout();
            diffContainer.setSpacing(true);
            for (I_CmsDiffProvider diff : m_diffs) {
                Optional<Component> optionalDiff = diff.diff(cms, bean1, bean2);
                if (optionalDiff.isPresent()) {
                    diffContainer.addComponent(optionalDiff.get());
                }
            }
            Panel panel = new Panel();
            panel.setSizeFull();
            diffContainer.setWidth("100%");
            diffContainer.setMargin(true);
            panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
            panel.setContent(diffContainer);
            openChildDialog(
                CmsHistoryDialog.this,
                panel,
                CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_COMPARE_0));
        }

    }
382446
public static void assertXpathValuesNotEqual(String controlXpath,
                                                 Document controlDocument,
                                                 String testXpath,
                                                 Document testDocument)
        throws XpathException {
        XpathEngine xpath = XMLUnit.newXpathEngine();
        String control = xpath.evaluate(controlXpath, controlDocument);
        String test = xpath.evaluate(testXpath, testDocument);
        if (control!=null) {
            if (control.equals(test)) {
                fail("Expected test value NOT to be equal to control but both were "
                     + test);
            }
        } else if (test == null) {
            fail("Expected test value NOT to be equal to control but both were empty");
        }
    }
791177
public static void assertXpathsNotEqual(String controlXpath,
                                            InputSource controlDocument,
                                            String testXpath,
                                            InputSource testDocument)
        throws SAXException, IOException, XpathException {
        assertXpathsNotEqual(controlXpath,
                             XMLUnit.buildControlDocument(controlDocument),
                             testXpath,
                             XMLUnit.buildTestDocument(testDocument));
    }
616322
private boolean checkElement(final StartElement mEvent) throws TTIOException {
        assert mEvent != null;
        boolean retVal = false;

        // Matching element names?
        if (mWtx.getNode().getKind() == IConstants.ELEMENT
            && mWtx.getQNameOfCurrentNode().equals(mEvent.getName())) {
            // Check if atts and namespaces are the same.
            final long nodeKey = mWtx.getNode().getDataKey();

            // Check attributes.
            boolean foundAtts = false;
            boolean hasAtts = false;
            for (final Iterator<?> it = mEvent.getAttributes(); it.hasNext();) {
                hasAtts = true;
                final Attribute attribute = (Attribute)it.next();
                for (int i = 0, attCount = ((ElementNode)mWtx.getNode()).getAttributeCount(); i < attCount; i++) {
                    mWtx.moveToAttribute(i);
                    if (attribute.getName().equals(mWtx.getQNameOfCurrentNode())
                        && attribute.getValue().equals(mWtx.getValueOfCurrentNode())) {
                        foundAtts = true;
                        mWtx.moveTo(nodeKey);
                        break;
                    }
                    mWtx.moveTo(nodeKey);
                }

                if (!foundAtts) {
                    break;
                }
            }
            if (!hasAtts && ((ElementNode)mWtx.getNode()).getAttributeCount() == 0) {
                foundAtts = true;
            }

            // Check namespaces.
            boolean foundNamesps = false;
            boolean hasNamesps = false;
            for (final Iterator<?> namespIt = mEvent.getNamespaces(); namespIt.hasNext();) {
                hasNamesps = true;
                final Namespace namespace = (Namespace)namespIt.next();
                for (int i = 0, namespCount = ((ElementNode)mWtx.getNode()).getNamespaceCount(); i < namespCount; i++) {
                    mWtx.moveToNamespace(i);
                    final ITreeNameData namenode = (ITreeNameData)mWtx.getNode();
                    if (namespace.getNamespaceURI().equals(mWtx.nameForKey(namenode.getURIKey()))
                        && namespace.getPrefix().equals(mWtx.nameForKey(namenode.getNameKey()))) {
                        foundNamesps = true;
                        mWtx.moveTo(nodeKey);
                        break;
                    }
                    mWtx.moveTo(nodeKey);
                }

                if (!foundNamesps) {
                    break;
                }
            }
            if (!hasNamesps && ((ElementNode)mWtx.getNode()).getNamespaceCount() == 0) {
                foundNamesps = true;
            }

            // Check if atts and namespaces are the same.
            if (foundAtts && foundNamesps) {
                retVal = true;
            } else {
                retVal = false;
            }
        }

        return retVal;
    }
660134
private DeferredComparison compareAttributeExplicitness(final Attr control,
                                                            final XPathContext controlContext,
                                                            final Attr test,
                                                            final XPathContext testContext) {
        return new DeferredComparison() {
            @Override
            public ComparisonState apply() {
                return compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED,
                                              control, getXPath(controlContext),
                                              control.getSpecified(), getParentXPath(controlContext),
                                              test, getXPath(testContext),
                                              test.getSpecified(), getParentXPath(testContext)));
            }
        };
    }
35806
private ComparisonState compareProcessingInstructions(ProcessingInstruction control,
                                                          XPathContext controlContext,
                                                          ProcessingInstruction test,
                                                          XPathContext testContext) {
        return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_TARGET,
                                      control, getXPath(controlContext),
                                      control.getTarget(), getParentXPath(controlContext),
                                      test, getXPath(testContext),
                                      test.getTarget(), getParentXPath(testContext)))
            .andThen(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA,
                                    control, getXPath(controlContext),
                                    control.getData(), getParentXPath(controlContext),
                                    test, getXPath(testContext),
                                    test.getData(), getParentXPath(testContext)));
    }
562134
private ComparisonState compareElementAttributes(final Element control,
                                                     final XPathContext controlContext,
                                                     final Element test,
                                                     final XPathContext testContext) {
        final Attributes controlAttributes = splitAttributes(control.getAttributes());
        controlContext
            .addAttributes(Linqy.map(controlAttributes.remainingAttributes,
                                     QNAME_MAPPER));
        final Attributes testAttributes = splitAttributes(test.getAttributes());
        testContext
            .addAttributes(Linqy.map(testAttributes.remainingAttributes,
                                     QNAME_MAPPER));

        return compare(new Comparison(ComparisonType.ELEMENT_NUM_ATTRIBUTES,
                                      control, getXPath(controlContext),
                                      controlAttributes.remainingAttributes.size(), getParentXPath(controlContext),
                                      test, getXPath(testContext),
                                      testAttributes.remainingAttributes.size(), getParentXPath(testContext)))
            .andThen(new DeferredComparison() {
                    @Override
                    public ComparisonState apply() {
                        return compareXsiType(controlAttributes.type, controlContext,
                                              testAttributes.type, testContext);
                    }
                })
            .andThen(new Comparison(ComparisonType.SCHEMA_LOCATION,
                                    control, getXPath(controlContext),
                                    controlAttributes.schemaLocation != null
                                    ? controlAttributes.schemaLocation.getValue() : null, getParentXPath(controlContext),
                                    test, getXPath(testContext),
                                    testAttributes.schemaLocation != null
                                    ? testAttributes.schemaLocation.getValue() : null, getParentXPath(testContext)))
            .andThen(new Comparison(ComparisonType.NO_NAMESPACE_SCHEMA_LOCATION,
                                    control, getXPath(controlContext),
                                    controlAttributes.noNamespaceSchemaLocation != null ?
                                    controlAttributes.noNamespaceSchemaLocation.getValue()
                                    : null, getParentXPath(controlContext),
                                    test, getXPath(testContext),
                                    testAttributes.noNamespaceSchemaLocation != null
                                    ? testAttributes.noNamespaceSchemaLocation.getValue()
                                    : null, getParentXPath(testContext)))
            .andThen(new NormalAttributeComparer(control, controlContext,
                                                 controlAttributes, test,
                                                 testContext, testAttributes));
    }
524404
protected void compareNodeChildren(Node control, Node test,
                                       DifferenceListener listener, ElementQualifier elementQualifier) 
        throws DifferenceFoundException {

        List<Node> controlChildren = nodeList2List(control.getChildNodes());
        List<Node> testChildren = nodeList2List(test.getChildNodes());

        Integer controlLength = new Integer(controlChildren.size());
        Integer testLength = new Integer(testChildren.size());
        compare(controlLength, testLength, control, test, listener,
                CHILD_NODELIST_LENGTH);

        if (control.hasChildNodes() || test.hasChildNodes()) {
            if (!control.hasChildNodes()) {
                for (Node aTestChildren : testChildren) {
                    missingNode(null, aTestChildren, listener);
                }
            } else if (!test.hasChildNodes()) {
                for (Node aControlChildren : controlChildren) {
                    missingNode(aControlChildren, null, listener);
                }
             } else {
                compareNodeList(controlChildren, testChildren,
                                controlLength.intValue(), listener, elementQualifier);
            }
        }
    }
519136
protected void compareComment(Comment control, Comment test,
                                  DifferenceListener listener) throws DifferenceFoundException {
        if (!XMLUnit.getIgnoreComments()) {
            compareCharacterData(control, test, listener, COMMENT_VALUE);
        }
    }
1194868
public static void assertXpathValuesNotEqual(String controlXpath,
                                                 String testXpath,
                                                 Document document)
        throws XpathException {
        assertXpathValuesNotEqual(controlXpath, document, testXpath, document);
    }
776
protected void compareRecognizedXMLSchemaInstanceAttribute(Attr control,
                                                               Attr test,
                                                               DifferenceListener listener)
        throws DifferenceFoundException {
        Attr nonNullNode = control != null ? control : test;
        Difference d = 
            XMLConstants.W3C_XML_SCHEMA_INSTANCE_SCHEMA_LOCATION_ATTR
            .equals(nonNullNode.getLocalName())
            ? SCHEMA_LOCATION : NO_NAMESPACE_SCHEMA_LOCATION;

        if (control != null) {
            controlTracker.visited(control);
        }
        if (test != null) {
            testTracker.visited(test);
        }
        
        compare(control != null ? control.getValue() : ATTRIBUTE_ABSENT,
                test != null ? test.getValue() : ATTRIBUTE_ABSENT,
                control, test, listener, d);
    }
186224
public static DiffBuilder compare(final Object control) {
        final Source controlSource = getSource(control);
        return new DiffBuilder(controlSource);
    }
648711
@Override
    public int compareTo(final MethodInfo other) {
        final int diff0 = declaringClassName.compareTo(other.declaringClassName);
        if (diff0 != 0) {
            return diff0;
        }
        final int diff1 = name.compareTo(other.name);
        if (diff1 != 0) {
            return diff1;
        }
        return typeDescriptorStr.compareTo(other.typeDescriptorStr);
    }
9057
protected void compareNode(Node control, Node test,
                               DifferenceListener listener, ElementQualifier elementQualifier) 
        throws DifferenceFoundException {
        boolean comparable = compareNodeBasics(control, test, listener);
        boolean isDocumentNode = false;

        if (comparable) {
            switch (control.getNodeType()) {
            case Node.ELEMENT_NODE:
                compareElement((Element)control, (Element)test, listener);
                break;
            case Node.CDATA_SECTION_NODE:
            case Node.TEXT_NODE:
                compareText((CharacterData) control,
                            (CharacterData) test, listener);
                break;
            case Node.COMMENT_NODE:
                compareComment((Comment)control, (Comment)test, listener);
                break;
            case Node.DOCUMENT_TYPE_NODE:
                compareDocumentType((DocumentType)control,
                                    (DocumentType)test, listener);
                break;
            case Node.PROCESSING_INSTRUCTION_NODE:
                compareProcessingInstruction((ProcessingInstruction)control,
                                             (ProcessingInstruction)test, listener);
                break;
            case Node.DOCUMENT_NODE:
                isDocumentNode = true;
                compareDocument((Document)control, (Document) test, 
                                listener, elementQualifier);
                break;
            default:
                listener.skippedComparison(control, test);
            }
        } 

        compareHasChildNodes(control, test, listener);
        if (isDocumentNode) {
            Element controlElement = ((Document)control).getDocumentElement();
            Element testElement = ((Document)test).getDocumentElement();
            if (controlElement!=null && testElement!=null) {
                compareNode(controlElement, testElement, listener, elementQualifier);
            }
        } else {
            controlTracker.indent();
            testTracker.indent();
            compareNodeChildren(control, test, listener, elementQualifier);
            controlTracker.outdent();
            testTracker.outdent();
        }
    }
1007412
public void fireComparisonPerformed(Comparison comparison,
                                        ComparisonResult outcome) {
        fire(comparison, outcome, compListeners);
        if (outcome == ComparisonResult.EQUAL) {
            fire(comparison, outcome, matchListeners);
        } else {
            fire(comparison, outcome, diffListeners);
        }
    }