@SuppressWarnings("PMD.AvoidUsingShortType") @Override public short compareDocumentPosition(org.w3c.dom.Node other) throws DOMException { return node.compareDocumentPosition(other); }
if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) { throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) { throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) { throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) { throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
/** * @param other * @return * @throws org.w3c.dom.DOMException * @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node) */ public short compareDocumentPosition(Node other) { return parent.compareDocumentPosition(other); }
public short compareDocumentPosition(Node other) throws DOMException { return this.domNode.compareDocumentPosition(other); }
@Override public short compareDocumentPosition(Node other) throws DOMException { return node.compareDocumentPosition(other); }
public final short compareDocumentPosition(org.w3c.dom.Node other) throws DOMException { return target.compareDocumentPosition(other); }
public final short compareDocumentPosition(org.w3c.dom.Node other) throws DOMException { return target.compareDocumentPosition(other); }
public short compareDocumentPosition(DOMNode other) throws DOMException { try { return _delegate.compareDocumentPosition(other.getDelegate()); } catch (org.w3c.dom.DOMException ex) { throw wrap(ex); } }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList elemList; Element elemName; Node entRef; int elementPosition; int entRefPosition; doc = (Document) load("hc_staff", false); elemList = doc.getElementsByTagName("var"); elemName = (Element) elemList.item(2); entRef = elemName.getFirstChild(); elementPosition = (int) elemName.compareDocumentPosition(entRef); assertEquals("nodecomparedocumentpositionIsContainedFollowing25", 20, elementPosition); entRefPosition = (int) entRef.compareDocumentPosition(elemName); assertEquals("nodecomparedocumentpositionContainsPRECEDING25", 10, entRefPosition); } /**
/** * Returns the last selection range in the current document, by document position. * @return the last selection range in the current document, by document position */ private Range getLastRange() { // avoid concurrent modification exception final List<Range> ranges = new ArrayList<>(getRanges()); Range last = null; for (final Range range : ranges) { if (last == null) { last = range; } else { final org.w3c.dom.Node lastStart = last.getStartContainer(); final org.w3c.dom.Node rangeStart = range.getStartContainer(); if ((lastStart.compareDocumentPosition(rangeStart) & Node.DOCUMENT_POSITION_FOLLOWING) != 0) { last = range; } } } return last; }
/** * Returns the first selection range in the current document, by document position. * @return the first selection range in the current document, by document position */ private Range getFirstRange() { // avoid concurrent modification exception final List<Range> ranges = new ArrayList<>(getRanges()); Range first = null; for (final Range range : ranges) { if (first == null) { first = range; } else { final org.w3c.dom.Node firstStart = first.getStartContainer(); final org.w3c.dom.Node rangeStart = range.getStartContainer(); if ((firstStart.compareDocumentPosition(rangeStart) & Node.DOCUMENT_POSITION_PRECEDING) != 0) { first = range; } } } return first; }
/** * Returns the first selection range in the current document, by document position. * @return the first selection range in the current document, by document position */ private Range getFirstRange() { // avoid concurrent modification exception final List<Range> ranges = new ArrayList<>(getRanges()); Range first = null; for (final Range range : ranges) { if (first == null) { first = range; } else { final org.w3c.dom.Node firstStart = first.getStartContainer(); final org.w3c.dom.Node rangeStart = range.getStartContainer(); if ((firstStart.compareDocumentPosition(rangeStart) & Node.DOCUMENT_POSITION_PRECEDING) != 0) { first = range; } } } return first; }
/** * Returns the last selection range in the current document, by document position. * @return the last selection range in the current document, by document position */ private Range getLastRange() { // avoid concurrent modification exception final List<Range> ranges = new ArrayList<>(getRanges()); Range last = null; for (final Range range : ranges) { if (last == null) { last = range; } else { final org.w3c.dom.Node lastStart = last.getStartContainer(); final org.w3c.dom.Node rangeStart = range.getStartContainer(); if ((lastStart.compareDocumentPosition(rangeStart) & Node.DOCUMENT_POSITION_FOLLOWING) != 0) { last = range; } } } return last; }
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); }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; DocumentFragment docFrag; Element docElem; Attr attr; Node docFragChild; int attrPosition; int docFragChildPosition; Node appendedChild; Node attrNode; doc = (Document) load("hc_staff", true); docElem = doc.getDocumentElement(); docFrag = doc.createDocumentFragment(); attr = doc.createAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang"); attrNode = docElem.setAttributeNodeNS(attr); appendedChild = docFrag.appendChild(docElem); docFragChild = docFrag.getFirstChild(); docFragChildPosition = (int) docFragChild.compareDocumentPosition(attr); assertEquals("nodecomparedocumentpositionIsContainedFollows15", 20, docFragChildPosition); attrPosition = (int) attr.compareDocumentPosition(docFragChild); assertEquals("nodecomparedocumentpositionPRECEEDINGContains15", 10, attrPosition); } /**
return false; final short startComparison = start.compareDocumentPosition(otherStart); final boolean startNodeBefore = startComparison == 0 || (startComparison & Node.DOCUMENT_POSITION_CONTAINS) != 0 final org.w3c.dom.Node end = range_.getEndContainer(); final org.w3c.dom.Node otherEnd = otherRange.getEndContainer(); final short endComparison = end.compareDocumentPosition(otherEnd); final boolean endNodeAfter = endComparison == 0 || (endComparison & Node.DOCUMENT_POSITION_CONTAINS) != 0
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; DocumentFragment docFrag; Element docElem; Node docFragChild; int docFragPosition; int docFragChildPosition; Node appendedChild; doc = (Document) load("hc_staff", true); docElem = doc.getDocumentElement(); docFrag = doc.createDocumentFragment(); appendedChild = docFrag.appendChild(docElem); docFragChild = docFrag.getFirstChild(); docFragPosition = (int) docFrag.compareDocumentPosition(docFragChild); assertEquals("nodecomparedocumentpositionContainsPRECEDING14", 20, docFragPosition); docFragChildPosition = (int) docFragChild.compareDocumentPosition(docFrag); assertEquals("nodecomparedocumentpositionIsContainedFollowing14", 10, docFragChildPosition); } /**