当前位置: 首页>>代码示例>>Java>>正文


Java Node.equals方法代码示例

本文整理汇总了Java中org.w3c.dom.Node.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Node.equals方法的具体用法?Java Node.equals怎么用?Java Node.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canGenerateSelectionXpath

import org.w3c.dom.Node; //导入方法依赖的package包/类
private boolean canGenerateSelectionXpath(boolean overwrite, Node node) {
	boolean bSelectionMenu = (currentAnchor == null);
	
	if (bSelectionMenu && !overwrite) {
		Node curNode = node instanceof Attr ? ((Attr) node).getOwnerElement() : node;
		Node root = node.getOwnerDocument().getFirstChild();
		if (curNode.equals(root)) {
			bSelectionMenu = false;
		} else {
			NodeList nodeList = root.getChildNodes();
			for (int i = 0; i < nodeList.getLength() && bSelectionMenu; i++) {
				bSelectionMenu = !nodeList.item(i).equals(curNode);
			}
		}
	}
	return bSelectionMenu;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:18,代码来源:XpathEvaluatorComposite.java

示例2: contains

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Tell if the table contains the given node.
 *
 * @param s Node to look for
 *
 * @return True if the given node was found.
 */
public boolean contains(Node s)
{
  runTo(-1);

  if (null == m_map)
    return false;

  for (int i = 0; i < m_firstFree; i++)
  {
    Node node = m_map[i];

    if ((null != node) && node.equals(s))
      return true;
  }

  return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:NodeSet.java

示例3: indexOf

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Searches for the first occurence of the given argument,
 * beginning the search at index, and testing for equality
 * using the equals method.
 *
 * @param elem Node to look for
 * @param index Index of where to start the search
 * @return the index of the first occurrence of the object
 * argument in this vector at position index or later in the
 * vector; returns -1 if the object is not found.
 */
public int indexOf(Node elem, int index)
{
  runTo(-1);

  if (null == m_map)
    return -1;

  for (int i = index; i < m_firstFree; i++)
  {
    Node node = m_map[i];

    if ((null != node) && node.equals(elem))
      return i;
  }

  return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NodeSet.java

示例4: indexOf

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Searches for the first occurence of the given argument,
 * beginning the search at index, and testing for equality
 * using the equals method.
 *
 * @param elem Node to look for
 * @return the index of the first occurrence of the object
 * argument in this vector at position index or later in the
 * vector; returns -1 if the object is not found.
 */
public int indexOf(Node elem)
{
  runTo(-1);

  if (null == m_map)
    return -1;

  for (int i = 0; i < m_firstFree; i++)
  {
    Node node = m_map[i];

    if ((null != node) && node.equals(elem))
      return i;
  }

  return -1;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:NodeSet.java

示例5: removeElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Removes the first occurrence of the argument from this vector.
 * If the object is found in this vector, each component in the vector
 * with an index greater or equal to the object's index is shifted
 * downward to have an index one smaller than the value it had
 * previously.
 *
 * @param s Node to remove from the list
 *
 * @return True if the node was successfully removed
 */
public boolean removeElement(Node s)
{
  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  if (null == m_map)
    return false;

  for (int i = 0; i < m_firstFree; i++)
  {
    Node node = m_map[i];

    if ((null != node) && node.equals(s))
    {
      if (i < m_firstFree - 1)
        System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);

      m_firstFree--;
      m_map[m_firstFree] = null;

      return true;
    }
  }

  return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:NodeSet.java

示例6: traverseFragment

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Perform a pre-order traversal non-recursive style.
 *
 * In contrast to the traverse() method this method will not issue
 * startDocument() and endDocument() events to the SAX listener.
 *
 * @param pos Node in the tree where to start traversal
 *
 * @throws TransformerException
 */
public void traverseFragment(Node pos) throws org.xml.sax.SAXException
{
  Node top = pos;

  while (null != pos)
  {
    startNode(pos);

    Node nextNode = pos.getFirstChild();

    while (null == nextNode)
    {
      endNode(pos);

      if (top.equals(pos))
        break;

      nextNode = pos.getNextSibling();

      if (null == nextNode)
      {
        pos = pos.getParentNode();

        if ((null == pos) || (top.equals(pos)))
        {
          if (null != pos)
            endNode(pos);

          nextNode = null;

          break;
        }
      }
    }

    pos = nextNode;
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:TreeWalker.java

示例7: traverse

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Perform a pre-order traversal non-recursive style.

 * Note that TreeWalker assumes that the subtree is intended to represent
 * a complete (though not necessarily well-formed) document and, during a
 * traversal, startDocument and endDocument will always be issued to the
 * SAX listener.
 *
 * @param pos Node in the tree where to start traversal
 * @param top Node in the tree where to end traversal
 *
 * @throws TransformerException
 */
public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
{

  this.m_contentHandler.startDocument();

  while (null != pos)
  {
    startNode(pos);

    Node nextNode = pos.getFirstChild();

    while (null == nextNode)
    {
      endNode(pos);

      if ((null != top) && top.equals(pos))
        break;

      nextNode = pos.getNextSibling();

      if (null == nextNode)
      {
        pos = pos.getParentNode();

        if ((null == pos) || ((null != top) && top.equals(pos)))
        {
          nextNode = null;

          break;
        }
      }
    }

    pos = nextNode;
  }
  this.m_contentHandler.endDocument();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:TreeWalker.java

示例8: areSameNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public boolean areSameNodes(Node n1, Node n2) {
    return n1.equals(n2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ReadOnlyAccess.java

示例9: calcXpath

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Compute the xpath of a node relative to an anchor.
 * 
 * @param node
 *            node to find the xpath from.
 * @param anchor
 *            the relative point to fid from.
 * @return the computed xpath.
 */
public static String calcXpath(Node node, Node anchor) {
	String xpath = "";
	Node current = null;

	if (node == null || node.equals(anchor))
		return "";

	// add attribute to xpath
	if (node instanceof Attr) {
		Attr attr = (Attr) node;
		node = attr.getOwnerElement();
		xpath = '@' + attr.getName() + '/';
	}

	while ((current = node.getParentNode()) != anchor) {
		Engine.logEngine.trace("Calc Xpath : current node : " + current.getNodeName());
		NodeList childs = current.getChildNodes();
		int index = 0;
		for (int i = 0; i < childs.getLength(); i++) {
			if (childs.item(i).getNodeType() != Node.ELEMENT_NODE
					&& !childs.item(i).getNodeName().equalsIgnoreCase("#text"))
				continue;

			Engine.logEngine.trace("Calc Xpath : ==== > Child node : " + childs.item(i).getNodeName());

			// Bump the index if we have the same tag names..
			if (childs.item(i).getNodeName().equalsIgnoreCase(node.getNodeName())) {
				// tag names are equal ==> bump the index.
				index++;
				// is our node the one that is listed ?
				if (childs.item(i).equals(node))
					// We found our node in the parent node list
					break;
			}
		}
		// count the number of elements having the same tag
		int nbElements = 0;
		for (int i = 0; i < childs.getLength(); i++) {
			if (childs.item(i).getNodeName().equalsIgnoreCase(node.getNodeName())) {
				nbElements++;
			}
		}

		String name = node.getNodeName();
		if (name.equalsIgnoreCase("#text"))
			name = "text()";
		name = xpathEscapeColon(name);

		if (nbElements > 1) {
			xpath = name + "[" + index + "]/" + xpath;
		} else {
			// only one element had the same tag ==> do not compute the [xx]
			// syntax..
			xpath = name + "/" + xpath;
		}
		node = current;
	}
	if (xpath.length() > 0)
		// remove the trailing '/'
		xpath = xpath.substring(0, xpath.length() - 1);

	return xpath;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:73,代码来源:XMLUtils.java

示例10: undeferChildren

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Traverses the DOM Tree and expands deferred nodes and their
 * children.
 *
 */
protected void undeferChildren(Node node) {

    Node top = node;

    while (null != node) {

        if (((NodeImpl)node).needsSyncData()) {
            ((NodeImpl)node).synchronizeData();
        }

        NamedNodeMap attributes = node.getAttributes();
        if (attributes != null) {
            int length = attributes.getLength();
            for (int i = 0; i < length; ++i) {
                undeferChildren(attributes.item(i));
            }
        }

        Node nextNode = null;
        nextNode = node.getFirstChild();

        while (null == nextNode) {

            if (top.equals(node))
                break;

            nextNode = node.getNextSibling();

            if (null == nextNode) {
                node = node.getParentNode();

                if ((null == node) || (top.equals(node))) {
                    nextNode = null;
                    break;
                }
            }
        }

        node = nextNode;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:CoreDocumentImpl.java

示例11: traverse

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Perform a pre-order traversal non-recursive style.
 *
 * Note that TreeWalker assumes that the subtree is intended to represent
 * a complete (though not necessarily well-formed) document and, during a
 * traversal, startDocument and endDocument will always be issued to the
 * SAX listener.
 *
 * @param pos Node in the tree where to start traversal
 *
 * @throws TransformerException
 */
public void traverse(Node pos) throws org.xml.sax.SAXException {
    this.fSerializer.startDocument();

    // Determine if the Node is a DOM Level 3 Core Node.
    if (pos.getNodeType() != Node.DOCUMENT_NODE) {
        Document ownerDoc = pos.getOwnerDocument();
        if (ownerDoc != null
            && ownerDoc.getImplementation().hasFeature("Core", "3.0")) {
            fIsLevel3DOM = true;
        }
    } else {
        if (((Document) pos)
            .getImplementation()
            .hasFeature("Core", "3.0")) {
            fIsLevel3DOM = true;
        }
    }

    if (fSerializer instanceof LexicalHandler) {
        fLexicalHandler = ((LexicalHandler) this.fSerializer);
    }

    if (fFilter != null)
        fWhatToShowFilter = fFilter.getWhatToShow();

    Node top = pos;

    while (null != pos) {
        startNode(pos);

        Node nextNode = null;

        nextNode = pos.getFirstChild();

        while (null == nextNode) {
            endNode(pos);

            if (top.equals(pos))
                break;

            nextNode = pos.getNextSibling();

            if (null == nextNode) {
                pos = pos.getParentNode();

                if ((null == pos) || (top.equals(pos))) {
                    if (null != pos)
                        endNode(pos);

                    nextNode = null;

                    break;
                }
            }
        }

        pos = nextNode;
    }
    this.fSerializer.endDocument();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:73,代码来源:DOM3TreeWalker.java


注:本文中的org.w3c.dom.Node.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。