org.apache.lucene.analysis
Class BaseCharFilter

java.lang.Object
  extended by java.io.Reader
      extended by org.apache.lucene.analysis.CharStream
          extended by org.apache.lucene.analysis.CharFilter
              extended by org.apache.lucene.analysis.BaseCharFilter
All Implemented Interfaces:
Closeable, Readable
Direct Known Subclasses:
MappingCharFilter

public abstract class BaseCharFilter
extends CharFilter

Base utility class for implementing a CharFilter. You subclass this, and then record mappings by calling addOffCorrectMap(int, int), and then invoke the correct method to correct an offset.

NOTE: This class is not particularly efficient. For example, a new class instance is created for every call to addOffCorrectMap(int, int), which is then appended to a private list.


Field Summary
 
Fields inherited from class org.apache.lucene.analysis.CharFilter
input
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
BaseCharFilter(CharStream in)
           
 
Method Summary
protected  void addOffCorrectMap(int off, int cumulativeDiff)
           
protected  int correct(int currentOff)
          Retrieve the corrected offset.
protected  int getLastCumulativeDiff()
           
 
Methods inherited from class org.apache.lucene.analysis.CharFilter
close, correctOffset, mark, markSupported, read, reset
 
Methods inherited from class java.io.Reader
read, read, read, ready, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseCharFilter

public BaseCharFilter(CharStream in)
Method Detail

correct

protected int correct(int currentOff)
Retrieve the corrected offset. Note that this method is slow, if you correct positions far before the most recently added position, as it's a simple linear search backwards through all offset corrections added by addOffCorrectMap(int, int).

Overrides:
correct in class CharFilter
Parameters:
currentOff - current offset
Returns:
corrected offset

getLastCumulativeDiff

protected int getLastCumulativeDiff()

addOffCorrectMap

protected void addOffCorrectMap(int off,
                                int cumulativeDiff)


Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.