Example #1
0
  /**
   * Tell if two objects are functionally equal.
   *
   * @param obj2 Object to compare this to
   * @return true if the two objects are equal
   * @throws javax.xml.transform.TransformerException
   */
  public boolean equals(XObject obj2) {

    // In order to handle the 'all' semantics of
    // nodeset comparisons, we always call the
    // nodeset function.
    int t = obj2.getType();
    try {
      if (XObject.CLASS_NODESET == t) return obj2.equals(this);
      // If at least one object to be compared is a boolean, then each object
      // to be compared is converted to a boolean as if by applying the
      // boolean function.
      else if (XObject.CLASS_BOOLEAN == t) return obj2.bool() == bool();
      // Otherwise, if at least one object to be compared is a number, then each object
      // to be compared is converted to a number as if by applying the number function.
      else if (XObject.CLASS_NUMBER == t) return obj2.num() == num();
    } catch (javax.xml.transform.TransformerException te) {
      throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(te);
    }

    // Otherwise, both objects to be compared are converted to strings as
    // if by applying the string function.
    return xstr().equals(obj2.xstr());
  }