Class BaseCharFilter
java.lang.Object
java.io.Reader
org.apache.lucene.analysis.CharFilter
org.apache.lucene.analysis.charfilter.BaseCharFilter
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Direct Known Subclasses:
CJKWidthCharFilter,HTMLStripCharFilter,ICUNormalizer2CharFilter,MappingCharFilter,PatternReplaceCharFilter
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.-
Field Summary
FieldsFields inherited from class org.apache.lucene.analysis.CharFilter
input -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOffCorrectMap(int off, int cumulativeDiff) Adds an offset correction mapping at the given output stream offset.protected intcorrect(int currentOff) Retrieve the corrected offset.protected intMethods inherited from class org.apache.lucene.analysis.CharFilter
close, correctOffset
-
Field Details
-
offsets
private int[] offsets -
diffs
private int[] diffs -
size
private int size
-
-
Constructor Details
-
BaseCharFilter
-
-
Method Details
-
correct
protected int correct(int currentOff) Retrieve the corrected offset.- Specified by:
correctin classCharFilter- Parameters:
currentOff- current offset- Returns:
- corrected offset
-
getLastCumulativeDiff
protected int getLastCumulativeDiff() -
addOffCorrectMap
protected void addOffCorrectMap(int off, int cumulativeDiff) Adds an offset correction mapping at the given output stream offset.
Assumption: the offset given with each successive call to this method will not be smaller than the offset given at the previous invocation.
- Parameters:
off- The output stream offset at which to apply the correctioncumulativeDiff- The input offset is given by adding this to the output offset
-