add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / facet / src / java / org / apache / lucene / facet / index / categorypolicy / OrdinalPolicy.java
1 package org.apache.lucene.facet.index.categorypolicy;
2
3 import java.io.Serializable;
4
5 import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
6 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
7
8 /**
9  * Licensed to the Apache Software Foundation (ASF) under one or more
10  * contributor license agreements.  See the NOTICE file distributed with
11  * this work for additional information regarding copyright ownership.
12  * The ASF licenses this file to You under the Apache License, Version 2.0
13  * (the "License"); you may not use this file except in compliance with
14  * the License.  You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24
25 /**
26  * Filtering category ordinals in {@link CategoryParentsStream}, where a given
27  * category ordinal is added to the stream, and than its parents are being added
28  * one after the other using {@link TaxonomyWriter#getParent(int)}. <br>
29  * That loop should have a stop point - the default approach (excluding the
30  * ROOT) is implemented in {@link DefaultOrdinalPolicy}.
31  * 
32  * @lucene.experimental
33  */
34 public interface OrdinalPolicy extends Serializable {
35
36   /**
37    * Check whether a given category ordinal should be added to the stream.
38    * 
39    * @param ordinal
40    *            A given category ordinal which is to be tested for stream
41    *            addition.
42    * @return <code>true</code> if the category should be added.
43    *         <code>false</code> otherwise.
44    */
45   public abstract boolean shouldAdd(int ordinal);
46
47   /**
48    * Initialize the policy with a TaxonomyWriter. This method can be
49    * implemented as noop if the ordinal policy is not taxonomy dependent
50    * 
51    * @param taxonomyWriter
52    *            A relevant taxonomyWriter object, with which ordinals sent to
53    *            {@link #shouldAdd(int)} are examined.
54    */
55   public abstract void init(TaxonomyWriter taxonomyWriter);
56 }