FileDocCategorySizeDatePackage
RegexTermEnum.javaAPI DocApache Lucene 1.92230Mon Feb 27 11:12:28 GMT 2006org.apache.lucene.search.regex

RegexTermEnum

public class RegexTermEnum extends FilteredTermEnum
Subclass of FilteredTermEnum for enumerating all terms that match the specified regular expression term using the specified regular expression implementation.

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

Fields Summary
private String
field
private String
pre
private boolean
endEnum
private RegexCapabilities
regexImpl
Constructors Summary
public RegexTermEnum(IndexReader reader, Term term, RegexCapabilities regexImpl)


           
    super();
    field = term.field();
    String text = term.text();
    this.regexImpl = regexImpl;

    regexImpl.compile(text);

    pre = regexImpl.prefix();
    if (pre == null) pre = "";

    setEnum(reader.terms(new Term(term.field(), pre)));
  
Methods Summary
public voidclose()

    super.close();
    field = null;
  
public final floatdifference()

// TODO: adjust difference based on distance of searchTerm.text() and term().text()
    return 1.0f;
  
public final booleanendEnum()

    return endEnum;
  
protected final booleantermCompare(org.apache.lucene.index.Term term)

    if (field == term.field()) {
      String searchText = term.text();
      if (searchText.startsWith(pre)) {
        return regexImpl.match(searchText);
      }
    }
    endEnum = true;
    return false;