@Override public boolean isSameNode(org.w3c.dom.Node other) { return node.isSameNode(other); }
@Override public int compare(Node arg0, Node arg1) { int response = -1; if (arg0.isSameNode(arg1)) { response = 0; } //determine if the element is an ancestor if (response != 0) { boolean eof = false; Node parentNode = arg0; while (!eof) { parentNode = parentNode.getParentNode(); if (parentNode == null) { eof = true; } else if (arg1.isSameNode(parentNode)) { response = 0; eof = true; } } } return response; } };
protected List<Element> getChildNodesByTagName(Element element, String tagName) { List<Element> list = new ArrayList<Element>(); NodeList nList = element.getElementsByTagName(tagName); if(nList.getLength() > 0) { for (int i = 0; i < nList.getLength(); i++) { Node node = nList.item(i); if(node.getParentNode().isSameNode(element) && node instanceof Element) list.add((Element) node); } } return list; } }
/** * Returns true if <code>m</code> is the same node <code>n</code>. */ private boolean isSameNode(Node m, Node n) { return (fUseIsSameNode) ? m.isSameNode(n) : m == n; } }
/** * @param other * @return * @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node) */ public boolean isSameNode(Node other) { return parent.isSameNode(other); }
public boolean isSameNode(Node other) { return this.domNode.isSameNode(other); }
@Override public boolean isSameNode(Node other) { return node.isSameNode(other); }
public final boolean isSameNode(org.w3c.dom.Node other) { return target.isSameNode(other); }
public final boolean isSameNode(org.w3c.dom.Node other) { return target.isSameNode(other); }
protected List<Element> getChildNodesByTagName(Element element, String tagName) { List<Element> list = new ArrayList<Element>(); NodeList nList = element.getElementsByTagName(tagName); if(nList.getLength() > 0) { for (int i = 0; i < nList.getLength(); i++) { Node node = nList.item(i); if(node.getParentNode().isSameNode(element) && node instanceof Element) list.add((Element) node); } } return list; } }
/** * Does the current element or some ancestor of it correspond to the known "signedElement"? */ private static boolean isElementOrAncestorSigned(Element elem, Element signedElement) throws WSSecurityException { final Element envelope = elem.getOwnerDocument().getDocumentElement(); Node cur = elem; while (!cur.isSameNode(envelope)) { if (cur.getNodeType() == Node.ELEMENT_NODE && cur.equals(signedElement)) { return true; } cur = cur.getParentNode(); } return false; }
/** * Does the current element or some ancestor of it correspond to the known "signedElement"? */ private static boolean isElementOrAncestorSigned(Element elem, Element signedElement) throws WSSecurityException { final Element envelope = elem.getOwnerDocument().getDocumentElement(); Node cur = elem; while (!cur.isSameNode(envelope)) { if (cur.getNodeType() == Node.ELEMENT_NODE && cur.equals(signedElement)) { return true; } cur = cur.getParentNode(); } return false; }
/** * Does the current element or some ancestor of it correspond to the known "signedElement"? */ private static boolean isElementOrAncestorSigned(Element elem, Element signedElement) throws WSSecurityException { final Element envelope = elem.getOwnerDocument().getDocumentElement(); Node cur = elem; while (!cur.isSameNode(envelope)) { if (cur.getNodeType() == Node.ELEMENT_NODE && cur.equals(signedElement)) { return true; } cur = cur.getParentNode(); } return false; }
public boolean isSameNode(DOMNode other) { return _delegate.isSameNode(other.getDelegate()); }
public static boolean same(NodeType a, NodeType b) { return (a.node_value().isSameNode(b.node_value())); // While compare_node(a, b) == 0 is tempting, it is also expensive }
private static int compare_node(NodeType a, NodeType b) { Node nodeA = a.node_value(); Node nodeB = b.node_value(); if (nodeA == nodeB || nodeA.isSameNode(nodeB)) return 0; Document docA = getDocument(nodeA); Document docB = getDocument(nodeB); if (docA != docB && ! docA.isSameNode(docB)) { return compareDocuments(docA, docB); } short relation = nodeA.compareDocumentPosition(nodeB); if ((relation & Node.DOCUMENT_POSITION_PRECEDING) != 0) return 1; if ((relation & Node.DOCUMENT_POSITION_FOLLOWING) != 0) return -1; throw new RuntimeException("Unexpected result from node comparison: " + relation); }
/** * returns parent accessors of the context node * * @param node * is the node type. * @throws dc * is the Dynamic context. */ public void iterate(NodeType node, ResultBuffer copyInto, Node limitNode) { Node n = node.node_value(); if (limitNode != null && limitNode.isSameNode(n)) { // no further, we have reached the limit node return; } Node parent = findParent(n); // if a parent exists... add it if (parent != null) { NodeType nodeType = NodeType.dom_to_xpath(parent, node.getTypeModel()); if(nodeType != null) { copyInto.add(nodeType); } } }
/** * Get the ancestors of the context node. * * @param node * is the type of node. */ // XXX unify this with descendants axis ? public void iterate(NodeType node, ResultBuffer copyInto, Node limitNode) { if (limitNode != null && limitNode.isSameNode(node.node_value())) return; int before = copyInto.size(); // get the parent super.iterate(node, copyInto, limitNode); // no parent if (copyInto.size() == before) return; NodeType parent = (NodeType) copyInto.item(before); // get ancestors of parent iterate(parent, copyInto, limitNode); }
/** * Determine whether this is the same node as another node. <br /> * Note: a.isSameNodeInfo(b) if and only if generateId(a)==generateId(b) * @return true if this Node object and the supplied Node object represent the * same node in the tree. */ public boolean isSameNodeInfo(NodeInfo other) { if (!(other instanceof NodeWrapper)) { return false; } if (docWrapper.domLevel3) { return node.isSameNode(((NodeWrapper)other).node); } else { NodeWrapper ow = (NodeWrapper)other; return getNodeKind()==ow.getNodeKind() && getNameCode()==ow.getNameCode() && // redundant, but gives a quick exit getSiblingPosition()==ow.getSiblingPosition() && getParent().isSameNodeInfo(ow.getParent()); } }
/** * Determine whether this is the same node as another node. * <p>Note: a.equals(b) if and only if generateId(a)==generateId(b)</p> * * @return true if this Node object and the supplied Node object represent the * same node in the tree. */ public boolean equals(Object other) { if (!(other instanceof DOMNodeWrapper)) { return false; } if (docWrapper.domLevel3) { synchronized (docWrapper.docNode) { return node.isSameNode(((DOMNodeWrapper) other).node); } } else { DOMNodeWrapper ow = (DOMNodeWrapper) other; return getNodeKind() == ow.getNodeKind() && equalOrNull(getLocalPart(), ow.getLocalPart()) && // redundant, but gives a quick exit getSiblingPosition() == ow.getSiblingPosition() && getParent().equals(ow.getParent()); } }