pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / java / org / apache / lucene / facet / search / CategoryListIterator.java
1 package org.apache.lucene.facet.search;
2
3 import java.io.IOException;
4
5 /**
6  * Licensed to the Apache Software Foundation (ASF) under one or more
7  * contributor license agreements.  See the NOTICE file distributed with
8  * this work for additional information regarding copyright ownership.
9  * The ASF licenses this file to You under the Apache License, Version 2.0
10  * (the "License"); you may not use this file except in compliance with
11  * the License.  You may obtain a copy of the License at
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 /**
23  * An interface for iterating over a "category list", i.e., the list of
24  * categories per document.
25  * <p>
26  * <b>NOTE:</b>
27  * <ul>
28  * <li>This class operates as a key to a Map. Appropriate implementation of
29  * <code>hashCode()</code> and <code>equals()</code> must be provided.
30  * <li>{@link #init()} must be called before you consume any categories, or call
31  * {@link #skipTo(int)}.
32  * <li>{@link #skipTo(int)} must be called before any calls to
33  * {@link #nextCategory()}.
34  * <li>{@link #nextCategory()} returns values &lt; {@link Integer#MAX_VALUE}, so
35  * you can use it as a stop condition.
36  * </ul>
37  * 
38  * @lucene.experimental
39  */
40 public interface CategoryListIterator {
41
42   /**
43    * Initializes the iterator. This method must be called before any calls to
44    * {@link #skipTo(int)}, and its return value indicates whether there are
45    * any relevant documents for this iterator. If it returns false, any call
46    * to {@link #skipTo(int)} will return false as well.<br>
47    * <b>NOTE:</b> calling this method twice may result in skipping over
48    * documents for some implementations. Also, calling it again after all
49    * documents were consumed may yield unexpected behavior.
50    */
51   public boolean init() throws IOException;
52
53   /**
54    * Skips forward to document docId. Returns true iff this document exists
55    * and has any categories. This method must be called before calling
56    * {@link #nextCategory()} for a particular document.<br>
57    * <b>NOTE:</b> Users should call this method with increasing docIds, and
58    * implementations can assume that this is the case.
59    */
60   public boolean skipTo(int docId) throws IOException;
61
62   /**
63    * Returns the next category for the current document that is set through
64    * {@link #skipTo(int)}, or a number higher than {@link Integer#MAX_VALUE}.
65    * No assumptions can be made on the order of the categories.
66    */
67   public long nextCategory() throws IOException;
68
69 }