public int compareChildNodePointers()

in src/main/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java [343:382]


    public int compareChildNodePointers(final NodePointer pointer1, final NodePointer pointer2) {
        final Node node1 = (Node) pointer1.getBaseValue();
        final Node node2 = (Node) pointer2.getBaseValue();
        if (node1 == node2) {
            return 0;
        }
        final int t1 = node1.getNodeType();
        final int t2 = node2.getNodeType();
        if (t1 == Node.ATTRIBUTE_NODE && t2 != Node.ATTRIBUTE_NODE) {
            return -1;
        }
        if (t1 != Node.ATTRIBUTE_NODE && t2 == Node.ATTRIBUTE_NODE) {
            return 1;
        }
        if (t1 == Node.ATTRIBUTE_NODE && t2 == Node.ATTRIBUTE_NODE) {
            final NamedNodeMap map = ((Node) getNode()).getAttributes();
            final int length = map.getLength();
            for (int i = 0; i < length; i++) {
                final Node n = map.item(i);
                if (n == node1) {
                    return -1;
                }
                if (n == node2) {
                    return 1;
                }
            }
            return 0; // Should not happen
        }
        Node current = node.getFirstChild();
        while (current != null) {
            if (current == node1) {
                return -1;
            }
            if (current == node2) {
                return 1;
            }
            current = current.getNextSibling();
        }
        return 0;
    }