FileDocCategorySizeDatePackage
FilteredTermEnum.javaAPI DocApache Lucene 1.4.33081Sat Jul 10 08:19:02 BST 2004org.apache.lucene.search

FilteredTermEnum

public abstract class FilteredTermEnum extends TermEnum
Abstract class for enumerating a subset of all terms.

Term enumerations are always ordered by Term.compareTo(). Each term in the enumeration is greater than all that precede it.

Fields Summary
private Term
currentTerm
private TermEnum
actualEnum
Constructors Summary
public FilteredTermEnum()

    
        
Methods Summary
public voidclose()
Closes the enumeration to further activity, freeing resources.

        actualEnum.close();
        currentTerm = null;
        actualEnum = null;
    
protected abstract floatdifference()
Equality measure on the term

public intdocFreq()
Returns the docFreq of the current Term in the enumeration. Initially invalid, valid after next() called for the first time.

        if (actualEnum == null) return -1;
        return actualEnum.docFreq();
    
protected abstract booleanendEnum()
Indiciates the end of the enumeration has been reached

public booleannext()
Increments the enumeration to the next element. True if one exists.

        if (actualEnum == null) return false; // the actual enumerator is not initialized!
        currentTerm = null;
        while (currentTerm == null) {
            if (endEnum()) return false;
            if (actualEnum.next()) {
                Term term = actualEnum.term();
                if (termCompare(term)) {
                    currentTerm = term;
                    return true;
                }
            }
            else return false;
        }
        currentTerm = null;
        return false;
    
protected voidsetEnum(org.apache.lucene.index.TermEnum actualEnum)

        this.actualEnum = actualEnum;
        // Find the first term that matches
        Term term = actualEnum.term();
        if (term != null && termCompare(term)) 
            currentTerm = term;
        else next();
    
public org.apache.lucene.index.Termterm()
Returns the current Term in the enumeration. Initially invalid, valid after next() called for the first time.

        return currentTerm;
    
protected abstract booleantermCompare(org.apache.lucene.index.Term term)
Equality compare on the term