public boolean equals(Object obj) {
    if (!(obj instanceof EmployeeLax)) {
      return false;
    }

    EmployeeLax emp = (EmployeeLax) obj;
    if (!(name.equals(emp.name))) {
      return false;
    }
    if (!(homeAddress.equals(emp.homeAddress))) {
      return false;
    }
    if (!(elements.size() == emp.elements.size())) {
      return false;
    }

    Iterator elements1 = this.elements.iterator();
    Iterator elements2 = emp.elements.iterator();
    XMLComparer comparer = new XMLComparer();

    while (elements1.hasNext()) {
      Object next1 = elements1.next();
      Object next2 = elements2.next();

      if ((next1 instanceof org.w3c.dom.Element) && (next2 instanceof Element)) {
        Element nextElem1 = (Element) next1;
        Element nextElem2 = (Element) next2;
        if (!(comparer.isNodeEqual(nextElem1, nextElem2))) {
          return false;
        }
      } else {
        if (!(next1.equals(next2))) {
          return false;
        }
      }
    }
    return true;
  }
Esempio n. 2
0
 public boolean equals(Object object) {
   try {
     Root theRoot = (Root) object;
     if (this == theRoot) {
       return true;
     }
     if (theObject == null) {
       return theRoot.getTheObject() == null;
     }
     if (theObject instanceof Node) {
       if (theRoot.getTheObject() instanceof Node) {
         // compare Nodes
         XMLComparer xmlComparer = new XMLComparer();
         return xmlComparer.isNodeEqual((Node) theObject, (Node) theRoot.getTheObject());
       } else {
         return false;
       }
     }
     return theObject.equals(theRoot.getTheObject());
   } catch (ClassCastException e) {
     return false;
   }
 }