1 package org.apache.lucene.facet.index.streaming;
3 import java.io.IOException;
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;
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;
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
23 * http://www.apache.org/licenses/LICENSE-2.0
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.
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}.
38 * @lucene.experimental
40 public abstract class CategoryTokenizerBase extends TokenFilter {
42 /** The stream's category attributes. */
43 protected CategoryAttribute categoryAttribute;
45 /** The stream's payload attribute. */
46 protected PayloadAttribute payloadAttribute;
48 /** The stream's term attribute. */
49 protected CharTermAttribute termAttribute;
51 /** The object used for constructing payloads. */
52 protected Payload payload = new Payload();
54 /** Indexing params for creating term text **/
55 protected FacetIndexingParams indexingParams;
61 * The input stream, either {@link CategoryParentsStream} or an
62 * extension of {@link CategoryTokenizerBase}.
63 * @param indexingParams
64 * The indexing params to use.
66 public CategoryTokenizerBase(TokenStream input,
67 FacetIndexingParams indexingParams) {
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;
76 public abstract boolean incrementToken() throws IOException;