<commit_before>package org.apache.lucene.search;

import java.io.IOException;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;

/**
 * Subclass of FilteredTermEnum for enumerating all terms that match the
 * specified prefix filter term.
 * <p>
 * Term enumerations are always ordered by Term.compareTo().  Each term in
 * the enumeration is greater than all that precede it.
 *
 */
public class PrefixTermEnum extends FilteredTermEnum {

  private Term prefix;
  private boolean endEnum = false;

  public PrefixTermEnum(IndexReader reader, Term prefix) throws IOException {
    this.prefix = prefix;

    setEnum(reader.terms(new Term(prefix.field(), prefix.text())));
  }

  public float difference() {
    return 1.0f;
  }

  protected boolean endEnum() {
    return endEnum;
  }

  protected boolean termCompare(Term term) {
    if (term.field() == prefix.field() && term.text().startsWith(prefix.text())) {                                                                              
      return true;
    }<commit_msg>LUCENE-1680: make prefix Term accessible<commit_after>package org.apache.lucene.search;

import java.io.IOException;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;

/**
 * Subclass of FilteredTermEnum for enumerating all terms that match the
 * specified prefix filter term.
 * <p>
 * Term enumerations are always ordered by Term.compareTo().  Each term in
 * the enumeration is greater than all that precede it.
 *
 */
public class PrefixTermEnum extends FilteredTermEnum {

  private final Term prefix;
  private boolean endEnum = false;

  public PrefixTermEnum(IndexReader reader, Term prefix) throws IOException {
    this.prefix = prefix;

    setEnum(reader.terms(new Term(prefix.field(), prefix.text())));
  }

  public float difference() {
    return 1.0f;
  }

  protected boolean endEnum() {
    return endEnum;
  }
  
  protected Term getPrefixTerm() {
      return prefix;
  }

  protected boolean termCompare(Term term) {
    if (term.field() == prefix.field() && term.text().startsWith(prefix.text())) {                                                                              
      return true;
    }
{'fraction_non_alphanumeric': 0.0970216606498195, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 2.7897435897435896, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2137393', 'n_tokens_mistral': 620, 'n_tokens_neox': 591, 'n_words': 182}