|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TermEnum | Line # 26 | 4 | 3 | 0% |
0.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | package org.apache.lucene.index; | |
| 2 | ||
| 3 | /** | |
| 4 | * Copyright 2004 The Apache Software Foundation | |
| 5 | * | |
| 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 | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 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. | |
| 17 | */ | |
| 18 | ||
| 19 | import java.io.IOException; | |
| 20 | ||
| 21 | /** Abstract class for enumerating terms. | |
| 22 | ||
| 23 | <p>Term enumerations are always ordered by Term.compareTo(). Each term in | |
| 24 | the enumeration is greater than all that precede it. */ | |
| 25 | ||
| 26 | public abstract class TermEnum { | |
| 27 | /** Increments the enumeration to the next element. True if one exists.*/ | |
| 28 | public abstract boolean next() throws IOException; | |
| 29 | ||
| 30 | /** Returns the current Term in the enumeration.*/ | |
| 31 | public abstract Term term(); | |
| 32 | ||
| 33 | /** Returns the docFreq of the current Term in the enumeration.*/ | |
| 34 | public abstract int docFreq(); | |
| 35 | ||
| 36 | /** Closes the enumeration to further activity, freeing resources. */ | |
| 37 | public abstract void close() throws IOException; | |
| 38 | ||
| 39 | // Term Vector support | |
| 40 | ||
| 41 | /** Skips terms to the first beyond the current whose value is | |
| 42 | * greater or equal to <i>target</i>. <p>Returns true iff there is such | |
| 43 | * an entry. <p>Behaves as if written: <pre> | |
| 44 | * public boolean skipTo(Term target) { | |
| 45 | * do { | |
| 46 | * if (!next()) | |
| 47 | * return false; | |
| 48 | * } while (target > term()); | |
| 49 | * return true; | |
| 50 | * } | |
| 51 | * </pre> | |
| 52 | * Some implementations are considerably more efficient than that. | |
| 53 | */ | |
| 54 | 0 |
public boolean skipTo(Term target) throws IOException { |
| 55 | 0 | do { |
| 56 | 0 | if (!next()) |
| 57 | 0 | return false; |
| 58 | 0 | } while (target.compareTo(term()) > 0); |
| 59 | 0 | return true; |
| 60 | } | |
| 61 | } | |
|
||||||||||