private int indexOf(Object obj, boolean first) { Expression expr = elements(); expr = new Filter (expr, new Equals (new Variable(m_element.getName()), new Literal(obj))); expr = new Sort(expr, new Variable(m_index.getName()), first ? Sort.ASCENDING : Sort.DESCENDING); expr = new Limit(expr, new Literal(new Integer(1))); Cursor c = C.cursor(ssn(), m_property.getType(), expr); try { if (c.next()) { ListElement el = (ListElement) c.get(); return el.getIndex().intValue(); } else { return -1; } } finally { c.close(); }
public int indexOf(Object element) { return m_indexOf(element).intValue();
    private int indexOf(Object obj, boolean first) {        Expression expr = elements();        expr = new Filter            (expr, new Equals             (new Variable(m_element.getName()), new Literal(obj)));        expr = new Sort(expr, new Variable(m_index.getName()),                        first ? Sort.ASCENDING : Sort.DESCENDING);        expr = new Limit(expr, new Literal(new Integer(1)));        Cursor c = C.cursor(ssn(), m_property.getType(), expr);        try {            if (c.next()) {                ListElement el = (ListElement) c.get();                return el.getIndex().intValue();            } else {                return -1;            }        } finally {            c.close();        }    }