FileDocCategorySizeDatePackage
FilteredTermEnum.javaAPI DocApache Lucene 2.1.03247Wed Feb 14 10:46:40 GMT 2007org.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;
    
public abstract floatdifference()
Equality measure on the term

public intdocFreq()
Returns the docFreq of the current Term in the enumeration. Returns -1 if no Term matches or all terms have been enumerated.

        if (actualEnum == null) return -1;
        return actualEnum.docFreq();
    
protected abstract booleanendEnum()
Indicates 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. Returns null if no Term matches or all terms have been enumerated.

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