private Query<?> getIndexEntryQuery(BoundaryType rangeStartBoundary,
                                        BoundaryType rangeEndBoundary)
        throws FetchException
    {
        Query<?>[] indexEntryQueryCache = mIndexEntryQueryCache;
        if (indexEntryQueryCache == null) {
            return null;
        }

        int key = 0;
        if (rangeEndBoundary != BoundaryType.OPEN) {
            key += (rangeEndBoundary == BoundaryType.INCLUSIVE) ? 1 : 2;
        }
        if (rangeStartBoundary != BoundaryType.OPEN) {
            key += (rangeStartBoundary == BoundaryType.INCLUSIVE) ? (1 * 3) : (2 * 3);
        }

        Query<?> indexEntryQuery = indexEntryQueryCache[key];

        if (indexEntryQuery == null) {
            indexEntryQuery = mSupport.indexEntryQuery(mIndex);
            Filter filter = indexEntryQuery.getFilter();

            int i;
            for (i=0; i<mIdentityCount; i++) {
                filter = filter.and(mIndex.getProperty(i).getName(), RelOp.EQ);
            }

            if (rangeStartBoundary != BoundaryType.OPEN) {
                RelOp op = (rangeStartBoundary == BoundaryType.INCLUSIVE) ? RelOp.GE : RelOp.GT;
                filter = filter.and(mIndex.getProperty(i).getName(), op);
            }

            if (rangeEndBoundary != BoundaryType.OPEN) {
                RelOp op = (rangeEndBoundary == BoundaryType.INCLUSIVE) ? RelOp.LE : RelOp.LT;
                filter = filter.and(mIndex.getProperty(i).getName(), op);
            }

            if (mCoveringFilter != null) {
                filter = filter.and(mCoveringFilter.unbind().toString());
            }

            indexEntryQuery = indexEntryQuery.and(filter);

            // Enforce index ordering where applicable.
            if (mIdentityCount < mIndex.getPropertyCount()) {
                String[] orderProperties = new String[mIdentityCount + 1];
                for (i=0; i<orderProperties.length; i++) {
                    Direction dir = mIndex.getPropertyDirection(i);
                    if (dir == Direction.UNSPECIFIED) {
                        dir = Direction.ASCENDING;
                    }
                    if (mReverseOrder) {
                        dir = dir.reverse();
                    }
                    orderProperties[i] = dir.toCharacter() + mIndex.getProperty(i).getName();
                }
                indexEntryQuery = indexEntryQuery.orderBy(orderProperties);
            }

            mIndexEntryQueryCache[key] = indexEntryQuery;
        }

        return indexEntryQuery;
    }
private Query < ? > getIndexEntryQuery ( BoundaryType rangeStartBoundary , BoundaryType rangeEndBoundary ) throws FetchException { Query < ? > [ ] indexEntryQueryCache = mIndexEntryQueryCache ; if ( indexEntryQueryCache == null ) { return null ; } int key = 0 ; if ( rangeEndBoundary != BoundaryType . OPEN ) { key += ( rangeEndBoundary == BoundaryType . INCLUSIVE ) ? 1 : 2 ; } if ( rangeStartBoundary != BoundaryType . OPEN ) { key += ( rangeStartBoundary == BoundaryType . INCLUSIVE ) ? ( 1 * 3 ) : ( 2 * 3 ) ; } Query < ? > indexEntryQuery = indexEntryQueryCache [ key ] ; if ( indexEntryQuery == null ) { indexEntryQuery = mSupport . indexEntryQuery ( mIndex ) ; Filter filter = indexEntryQuery . getFilter ( ) ; int i ; for ( i = 0 ; i < mIdentityCount ; i ++ ) { filter = filter . and ( mIndex . getProperty ( i ) . getName ( ) , RelOp . EQ ) ; } if ( rangeStartBoundary != BoundaryType . OPEN ) { RelOp op = ( rangeStartBoundary == BoundaryType . INCLUSIVE ) ? RelOp . GE : RelOp . GT ; filter = filter . and ( mIndex . getProperty ( i ) . getName ( ) , op ) ; } if ( rangeEndBoundary != BoundaryType . OPEN ) { RelOp op = ( rangeEndBoundary == BoundaryType . INCLUSIVE ) ? RelOp . LE : RelOp . LT ; filter = filter . and ( mIndex . getProperty ( i ) . getName ( ) , op ) ; } if ( mCoveringFilter != null ) { filter = filter . and ( mCoveringFilter . unbind ( ) . toString ( ) ) ; } indexEntryQuery = indexEntryQuery . and ( filter ) ; if ( mIdentityCount < mIndex . getPropertyCount ( ) ) { String [ ] orderProperties = new String [ mIdentityCount + 1 ] ; for ( i = 0 ; i < orderProperties . length ; i ++ ) { Direction dir = mIndex . getPropertyDirection ( i ) ; if ( dir == Direction . UNSPECIFIED ) { dir = Direction . ASCENDING ; } if ( mReverseOrder ) { dir = dir . reverse ( ) ; } orderProperties [ i ] = dir . toCharacter ( ) + mIndex . getProperty ( i ) . getName ( ) ; } indexEntryQuery = indexEntryQuery . orderBy ( orderProperties ) ; } mIndexEntryQueryCache [ key ] = indexEntryQuery ; } return indexEntryQuery ; }
@return null if query not supported