public int compareChildNodePointers()

in src/main/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java [168:217]


    public int compareChildNodePointers(
        final NodePointer pointer1,
        final NodePointer pointer2) {
        final Object node1 = pointer1.getBaseValue();
        final Object node2 = pointer2.getBaseValue();
        if (node1 == node2) {
            return 0;
        }

        if (node1 instanceof Attribute && !(node2 instanceof Attribute)) {
            return -1;
        }
        if (
            !(node1 instanceof Attribute) && node2 instanceof Attribute) {
            return 1;
        }
        if (
            node1 instanceof Attribute && node2 instanceof Attribute) {
            final List list = ((Element) getNode()).getAttributes();
            final int length = list.size();
            for (int i = 0; i < length; i++) {
                final Object n = list.get(i);
                if (n == node1) {
                    return -1;
                }
                else if (n == node2) {
                    return 1;
                }
            }
            return 0; // Should not happen
        }

        if (!(node instanceof Element)) {
            throw new IllegalStateException("JXPath internal error: " + "compareChildNodes called for " + node);
        }

        final List children = ((Element) node).getContent();
        final int length = children.size();
        for (int i = 0; i < length; i++) {
            final Object n = children.get(i);
            if (n == node1) {
                return -1;
            }
            if (n == node2) {
                return 1;
            }
        }

        return 0;
    }