pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / java / org / apache / lucene / facet / index / categorypolicy / NonTopLevelPathPolicy.java
1 package org.apache.lucene.facet.index.categorypolicy;
2
3 import org.apache.lucene.facet.taxonomy.CategoryPath;
4 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
5
6 /**
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements.  See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License.  You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22
23 /**
24  * This class filters our the ROOT category, and it's direct descendants. For
25  * more information see {@link PathPolicy}.
26  * 
27  * @lucene.experimental
28  */
29 public class NonTopLevelPathPolicy implements PathPolicy {
30
31   /**
32    * The shortest path length delivered is two components (root + one child).
33    */
34   public final int DEFAULT_MINIMAL_SUBPATH_LENGTH = 2;
35
36   /**
37    * Filters out (returns false) CategoryPaths equal or less than
38    * {@link TaxonomyReader#ROOT_ORDINAL}. true otherwise.
39    */
40   public boolean shouldAdd(CategoryPath categoryPath) {
41     return categoryPath.length() >= DEFAULT_MINIMAL_SUBPATH_LENGTH;
42   }
43 }