1 package org.apache.lucene.store.instantiated;
4 * Copyright 2006 The Apache Software Foundation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.apache.lucene.index.Term;
20 import org.apache.lucene.index.TermEnum;
23 * A {@link org.apache.lucene.index.TermEnum} navigating an {@link org.apache.lucene.store.instantiated.InstantiatedIndexReader}.
25 public class InstantiatedTermEnum extends TermEnum {
27 private final InstantiatedIndexReader reader;
29 public InstantiatedTermEnum(InstantiatedIndexReader reader) {
30 this.nextTermIndex = 0;
34 public InstantiatedTermEnum(InstantiatedIndexReader reader, int startPosition) {
36 this.nextTermIndex = startPosition;
40 private int nextTermIndex;
41 private InstantiatedTerm term;
44 * Increments the enumeration to the next element. True if one exists.
47 public boolean next() {
48 if (reader.getIndex().getOrderedTerms().length <= nextTermIndex) {
51 term = reader.getIndex().getOrderedTerms()[nextTermIndex];
58 * Returns the current Term in the enumeration.
62 return term == null ? null : term.getTerm();
66 * Returns the docFreq of the current Term in the enumeration.
69 public int docFreq() {
70 return term.getAssociatedDocuments().length;
74 * Closes the enumeration to further activity, freeing resources.