Package org.apache.lucene.analysis
Class CharFilter
- java.lang.Object
-
- java.io.Reader
-
- org.apache.lucene.analysis.CharFilter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
- Direct Known Subclasses:
BaseCharFilter,JapaneseIterationMarkCharFilter,PersianCharFilter
public abstract class CharFilter extends java.io.ReaderSubclasses of CharFilter can be chained to filter a Reader They can be used asReaderwith additional offset correction.Tokenizers will automatically usecorrectOffset(int)if a CharFilter subclass is used.This class is abstract: at a minimum you must implement
Reader.read(char[], int, int), transforming the input in some way frominput, andcorrect(int)to adjust the offsets to match the originals.You can optionally provide more efficient implementations of additional methods like
Reader.read(),Reader.read(char[]),Reader.read(java.nio.CharBuffer), but this is not required.For examples and integration with
Analyzer, see theAnalysis package documentation.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.ReaderinputThe underlying character-input stream.
-
Constructor Summary
Constructors Constructor Description CharFilter(java.io.Reader input)Create a new CharFilter wrapping the provided reader.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying input stream.protected abstract intcorrect(int currentOff)Subclasses override to correct the current offset.intcorrectOffset(int currentOff)Chains the corrected offset through the input CharFilter(s).
-
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionCloses the underlying input stream.NOTE: The default implementation closes the input Reader, so be sure to call
super.close()when overriding this method.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException
-
correct
protected abstract int correct(int currentOff)
Subclasses override to correct the current offset.- Parameters:
currentOff- current offset- Returns:
- corrected offset
-
correctOffset
public final int correctOffset(int currentOff)
Chains the corrected offset through the input CharFilter(s).
-
-