add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / facet / src / java / org / apache / lucene / facet / index / streaming / CategoryTokenizerBase.java
1 package org.apache.lucene.facet.index.streaming;
2
3 import java.io.IOException;
4
5 import org.apache.lucene.analysis.TokenFilter;
6 import org.apache.lucene.analysis.TokenStream;
7 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
8 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
9 import org.apache.lucene.index.Payload;
10
11 import org.apache.lucene.facet.index.CategoryDocumentBuilder;
12 import org.apache.lucene.facet.index.attributes.CategoryAttribute;
13 import org.apache.lucene.facet.index.params.FacetIndexingParams;
14
15 /**
16  * Licensed to the Apache Software Foundation (ASF) under one or more
17  * contributor license agreements.  See the NOTICE file distributed with
18  * this work for additional information regarding copyright ownership.
19  * The ASF licenses this file to You under the Apache License, Version 2.0
20  * (the "License"); you may not use this file except in compliance with
21  * the License.  You may obtain a copy of the License at
22  *
23  *     http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS,
27  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  */
31
32 /**
33  * A base class for all token filters which add term and payload attributes to
34  * tokens and are to be used in {@link CategoryDocumentBuilder}. Contains three
35  * attributes: {@link CategoryAttribute}, {@link CharTermAttribute} and
36  * {@link PayloadAttribute}.
37  * 
38  * @lucene.experimental
39  */
40 public abstract class CategoryTokenizerBase extends TokenFilter {
41
42   /** The stream's category attributes. */
43   protected CategoryAttribute categoryAttribute;
44
45   /** The stream's payload attribute. */
46   protected PayloadAttribute payloadAttribute;
47
48   /** The stream's term attribute. */
49   protected CharTermAttribute termAttribute;
50
51   /** The object used for constructing payloads. */
52   protected Payload payload = new Payload();
53
54   /** Indexing params for creating term text **/
55   protected FacetIndexingParams indexingParams;
56
57   /**
58    * Constructor.
59    * 
60    * @param input
61    *            The input stream, either {@link CategoryParentsStream} or an
62    *            extension of {@link CategoryTokenizerBase}.
63    * @param indexingParams
64    *            The indexing params to use.
65    */
66   public CategoryTokenizerBase(TokenStream input,
67       FacetIndexingParams indexingParams) {
68     super(input);
69     this.categoryAttribute = this.addAttribute(CategoryAttribute.class);
70     this.termAttribute = this.addAttribute(CharTermAttribute.class);
71     this.payloadAttribute = this.addAttribute(PayloadAttribute.class);
72     this.indexingParams = indexingParams;
73   }
74
75   @Override
76   public abstract boolean incrementToken() throws IOException;
77
78 }