org.w3c.dom.Node.isEqualNode()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.w3c.dom.Node.isEqualNode()方法的一些代码示例,展示了Node.isEqualNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.isEqualNode()方法的具体详情如下:
包路径:org.w3c.dom.Node
类名称:Node
方法名:isEqualNode

Node.isEqualNode介绍

[英]Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:

  • The two nodes are of the same type.
  • The following string attributes are equal: nodeName, localName, namespaceURI, prefix, nodeValue . This is: they are both null, or they have the same length and are character for character identical.
  • The attributes``NamedNodeMaps are equal. This is: they are both null, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.
  • The childNodes``NodeLists are equal. This is: they are both null, or they have the same length and contain equal nodes at the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.

For two DocumentType nodes to be equal, the following conditions must also be satisfied:

  • The following string attributes are equal: publicId, systemId, internalSubset.
  • The entities``NamedNodeMaps are equal.
  • The notations``NamedNodeMaps are equal.

On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.

Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.
[中]测试两个节点是否相等。
该方法测试的是节点的相等性,而不是相同性(即两个节点是否引用了同一对象),可以使用Node.isSameNode()进行测试。所有相同的节点也将是相等的,尽管反过来可能不是真的。
当且仅当满足以下条件时,两个节点相等:
*这两个节点属于同一类型。
*以下字符串属性相等:nodeNamelocalNamenamespaceURIprefixnodeValue。这就是:它们都是[$6$],或者它们的长度相同,并且每个字符都相同。
*attributes``NamedNodeMaps是相等的。这是:它们都是null,或者它们具有相同的长度,并且对于存在于一个映射中的每个节点,存在于另一个映射中的节点是相等的,尽管不一定位于相同的索引。
*childNodes``NodeLists是相等的。这是:它们都是null,或者它们具有相同的长度,并且在相同的索引中包含相同的节点。注意,规范化会影响平等;为了避免这种情况,应该在比较节点之前对其进行规范化。
要使两个DocumentType节点相等,还必须满足以下条件:
*以下字符串属性相等:publicIdsystemIdinternalSubset
*entities``NamedNodeMaps是相等的。
*notations``NamedNodeMaps是相等的。
另一方面,以下内容不影响相等性:ownerDocumentbaseURIparentNode属性、Attr节点的specified属性、AttrElement节点的schemaTypeInfo属性、Text节点的Text.isElementContentWhitespace属性以及在节点上注册的任何用户数据或事件侦听器。
注:作为一般规则,上述说明中未提及的任何内容在平等性检查方面都不重要。请注意,本规范的未来版本可能会考虑更多属性,符合本规范的实现预计会相应更新。

代码示例

代码示例来源:origin: pmd/pmd

@Override
public boolean isEqualNode(org.w3c.dom.Node arg) {
  return node.isEqualNode(arg);
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

protected boolean exactNodeExists(Node[] primaryNodes, Node testNode, List<Node> usedNodes) {
  for (int j = 0; j < primaryNodes.length; j++) {
    if (primaryNodes[j].isEqualNode(testNode)) {
      usedNodes.add(primaryNodes[j]);
      return true;
    }
  }
  return false;
}

代码示例来源:origin: robovm/robovm

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: robovm/robovm

|| !((Node) a).isEqualNode((Node) b)) {
return false;

代码示例来源:origin: xyz.cofe/common

@Override
public boolean isEqualNode(Node arg) {
  return node.isEqualNode(arg);
}

代码示例来源:origin: fbacchella/jrds

/**
 * @param arg
 * @return
 * @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
 */
public boolean isEqualNode(Node arg) {
  return parent.isEqualNode(arg);
}

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

public boolean isEqualNode(Node arg)
{
 return domNode.isEqualNode(arg);
}

代码示例来源:origin: apache/axis2-java

public final boolean isEqualNode(org.w3c.dom.Node arg) {
  return target.isEqualNode(arg);
}

代码示例来源:origin: org.apache.axis2/axis2-saaj

public final boolean isEqualNode(org.w3c.dom.Node arg) {
  return target.isEqualNode(arg);
}

代码示例来源:origin: org.vx68k.quercus/quercus

public boolean isEqualNode(DOMNode arg)
{
 return _delegate.isEqualNode(arg.getDelegate());
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: MobiVM/robovm

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: ibinti/bugvm

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: FlexoVM/flexovm

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.bugvm/bugvm-rt

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.gluonhq/robovm-rt

private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) {
  if (a.getLength() != b.getLength()) {
    return false;
  }
  for (int i = 0; i < a.getLength(); i++) {
    Node aNode = a.item(i);
    Node bNode = aNode.getLocalName() == null
        ? b.getNamedItem(aNode.getNodeName())
        : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName());
    if (bNode == null || !aNode.isEqualNode(bNode)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.hudsonci.xpath/xpath-service

@Override
public boolean isEqualNode(Node node) {
 if (node.getNodeType() != Node.DOCUMENT_TYPE_NODE) return false;
 DocumentType other = (DocumentType) node;
 if (!isEq(getPublicId(), other.getPublicId())) return false;
 if (!isEq(getSystemId(), other.getSystemId())) return false;
 NamedNodeMap thisEnts = getEntities();
 NamedNodeMap nodeEnts = other.getEntities();
 int len = thisEnts.getLength();
 if (len != nodeEnts.getLength()) return false;
 for (int i = 0; i < len; i++) {
  if (!thisEnts.item(i).isEqualNode(nodeEnts.item(i)))
   return false;
 }
 return true;
}

代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite

/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void runTest() throws Throwable {
 Document doc;
 Object userData;
 Object retUserData;
 boolean success;
 Element elem;
 Object returnedUserData;
 UserDataHandler nullHandler = null;
 doc = (Document) load("barfoo", false);
 elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "body");
 returnedUserData = doc.setUserData("something", ((Object) /*Node */elem), nullHandler);
 retUserData = doc.getUserData("something");
 success = ((Node) /*DOMUserData */retUserData).isEqualNode(elem);
 assertTrue("nodegetuserdata03", success);
 }
/**

代码示例来源:origin: fujitsu-pio/io

/**
 * XMLのレスポンスに期待するノード情報と同じ情報が含まれるかどうかをチェックする.
 * @param res PROPFINDレスポンス
 * @param tagName チェック対象となるタグ名
 * @param expectedNode 期待するノード情報
 */
public static void assertEqualsNodeInResXml(TResponse res, String tagName, Node expectedNode) {
  Document propfind = res.bodyAsXml();
  NodeList list;
  list = propfind.getElementsByTagName(tagName);
  for (int i = 0; i < list.getLength(); i++) {
    Node item = list.item(i);
    if (item.isEqualNode(expectedNode)) {
      return;
    }
  }
  // 指定されたタグが含まれない場合はテスト失敗とする
  fail();
}

代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite

/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void runTest() throws Throwable {
 Document doc;
 DocumentType docType;
 Object userData;
 Object retUserData;
 boolean success;
 UserDataHandler nullHandler = null;
 Object prevUserData;
 doc = (Document) load("hc_staff", false);
 docType = doc.getDoctype();
 prevUserData = docType.setUserData("KeyDoc", ((Object) /*Node */doc), nullHandler);
 retUserData = docType.getUserData("KeyDoc");
 success = ((Node) /*DOMUserData */retUserData).isEqualNode(doc);
 assertTrue("nodegetuserdata04", success);
 }
/**

相关文章