package org.apache.solr.analysis;
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.Reader;
import java.util.Map;

import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.path.PathHierarchyTokenizer;


/**
 * Factory for {@link PathHierarchyTokenizer}. 
 * <pre class="prettyprint" >
 * &lt;fieldType name="text_path" class="solr.TextField" positionIncrementGap="100"&gt;
 *   &lt;analyzer&gt;
 *     &lt;tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="\" replace="/"/&gt;
 *   &lt;/analyzer&gt;
 * &lt;/fieldType&gt;</pre> 
 * @version $Id$
 */
public class PathHierarchyTokenizerFactory extends BaseTokenizerFactory {
  
  private char delimiter;
  private char replacement;
  
  /**
   * Require a configured pattern
   */
  @Override
  public void init(Map<String,String> args){
    super.init( args );
    
    String v = args.get( "delimiter" );
    if( v != null ){
      if( v.length() != 1 ){
        throw new IllegalArgumentException( "delimiter should be a char. \"" + v + "\" is invalid" );
      }
      else{
        delimiter = v.charAt(0);
      }
    }
    else{
      delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
    }
    
    v = args.get( "replace" );
    if( v != null ){
      if( v.length() != 1 ){
        throw new IllegalArgumentException( "replace should be a char. \"" + v + "\" is invalid" );
      }
      else{
        replacement = v.charAt(0);
      }
    }
    else{
      replacement = delimiter;
    }
  }

  public Tokenizer create(Reader input) {
    return new PathHierarchyTokenizer(input, delimiter, replacement);
  }
}



@@ -985,16 +985,86 @@
 enizer;%0A
+import org.apache.lucene.analysis.path.ReversePathHierarchyTokenizer;%0A
 %0A%0A/**%0A *
@@ -1548,16 +1548,110 @@
 cement;%0A
+  private boolean reverse = false;%0A  private int skip =  PathHierarchyTokenizer.DEFAULT_SKIP;%0A
   %0A  /**
@@ -2414,16 +2414,207 @@
 ;%0A    %7D%0A
+    %0A    v = args.get( %22reverse%22 );%0A    if( v != null )%7B%0A      reverse = %22true%22.equals( v );%0A    %7D%0A%0A    v = args.get( %22skip%22 );%0A    if( v != null )%7B%0A      skip = Integer.parseInt( v );%0A    %7D%0A
   %7D%0A%0A  p
@@ -2652,16 +2652,38 @@
 nput) %7B%0A
+    if( reverse ) %7B%0A  
     retu
@@ -2689,16 +2689,23 @@
 urn new 
+Reverse
 PathHier
@@ -2748,16 +2748,104 @@
 lacement
+, skip);%0A    %7D%0A    return new PathHierarchyTokenizer(input, delimiter, replacement, skip
 );%0A  %7D%0A%7D

Add ReversePathHierarchyTokenizer and enable skip on PathHierarchyTokenizer