1 package org.apache.lucene.facet.search;
3 import java.io.IOException;
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * An interface for iterating over a "category list", i.e., the list of
24 * categories per document.
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 < {@link Integer#MAX_VALUE}, so
35 * you can use it as a stop condition.
38 * @lucene.experimental
40 public interface CategoryListIterator {
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.
51 public boolean init() throws IOException;
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.
60 public boolean skipTo(int docId) throws IOException;
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.
67 public long nextCategory() throws IOException;