1 package org.apache.lucene.facet.index.streaming;
3 import java.io.IOException;
5 import org.apache.lucene.analysis.TokenStream;
6 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
7 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
9 import org.apache.lucene.facet.index.params.FacetIndexingParams;
10 import org.apache.lucene.facet.taxonomy.CategoryPath;
13 * Licensed to the Apache Software Foundation (ASF) under one or more
14 * contributor license agreements. See the NOTICE file distributed with
15 * this work for additional information regarding copyright ownership.
16 * The ASF licenses this file to You under the Apache License, Version 2.0
17 * (the "License"); you may not use this file except in compliance with
18 * the License. You may obtain a copy of the License at
20 * http://www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
30 * Basic class for setting the {@link CharTermAttribute}s and
31 * {@link PayloadAttribute}s of category tokens.
33 * @lucene.experimental
35 public class CategoryTokenizer extends CategoryTokenizerBase {
38 * @see CategoryTokenizerBase#CategoryTokenizerBase(TokenStream,
39 * FacetIndexingParams)
41 public CategoryTokenizer(TokenStream input,
42 FacetIndexingParams indexingParams) {
43 super(input, indexingParams);
47 public final boolean incrementToken() throws IOException {
48 if (input.incrementToken()) {
49 if (categoryAttribute != null && categoryAttribute.getCategoryPath() != null) {
50 CategoryPath categoryPath = categoryAttribute.getCategoryPath();
51 char[] termBuffer = termAttribute.resizeBuffer(categoryPath.charsNeededForFullPath());
52 int nChars = indexingParams.drillDownTermText(categoryPath, termBuffer);
53 termAttribute.setLength(nChars);
62 * Set the payload of the current category token.
64 protected void setPayload() {