Class CharFilter
Subclasses of CharFilter can be chained to filter a System.IO.TextReader They can be used as System.IO.TextReader with additional offset correction. Tokenizers will automatically use CorrectOffset(Int32) if a CharFilter subclass is used.
This class is abstract: at a minimum you must implement System.IO.TextReader.Read(System.Char[], System.Int32, System.Int32), transforming the input in some way from m_input, and Correct(Int32) to adjust the offsets to match the originals.
You can optionally provide more efficient implementations of additional methods like System.IO.TextReader.Read(), but this is not required.
For examples and integration with Analyzer, see the Lucene.Net.Analysis namespace documentation.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Analysis
Assembly: Lucene.Net.dll
Syntax
public abstract class CharFilter : TextReader, IDisposable
Constructors
| Improve this Doc View SourceCharFilter(TextReader)
Create a new CharFilter wrapping the provided reader.
Declaration
protected CharFilter(TextReader input)
Parameters
Type | Name | Description |
---|---|---|
System.IO.TextReader | input | a System.IO.TextReader, can also be a CharFilter for chaining. |
Fields
| Improve this Doc View Sourcem_input
The underlying character-input stream.
Declaration
protected readonly TextReader m_input
Field Value
Type | Description |
---|---|
System.IO.TextReader |
Properties
| Improve this Doc View SourceIsMarkSupported
Tells whether this stream supports the Mark(Int32) operation. The default implementation always returns false. Subclasses should override this method.
LUCENENET specific. Moved here from the Reader class (in Java) so it can be overridden to provide reader buffering.
Declaration
public virtual bool IsMarkSupported { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if and only if this stream supports the mark operation. |
IsReady
Tells whether this stream is ready to be read.
True if the next System.IO.TextReader.Read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
LUCENENET specific. Moved here from the Reader class (in Java) so it can be overridden to provide reader buffering.
Declaration
public virtual bool IsReady { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCorrect(Int32)
Subclasses override to correct the current offset.
Declaration
protected abstract int Correct(int currentOff)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | currentOff | current offset |
Returns
Type | Description |
---|---|
System.Int32 | corrected offset |
CorrectOffset(Int32)
Chains the corrected offset through the input CharFilter(s).
Declaration
public int CorrectOffset(int currentOff)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | currentOff |
Returns
Type | Description |
---|---|
System.Int32 |
Dispose(Boolean)
Closes the underlying input stream.
NOTE:
The default implementation closes the input System.IO.TextReader, so
be sure to call base.Dispose(disposing)
when overriding this method.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
Mark(Int32)
Marks the present position in the stream. Subsequent calls to Reset() will attempt to reposition the stream to this point. Not all character-input streams support the Mark(Int32) operation.
LUCENENET specific. Moved here from the Reader class (in Java) so it can be overridden to provide reader buffering.
Declaration
public virtual void Mark(int readAheadLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | readAheadLimit | Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail. |
Read()
Declaration
public override int Read()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Read(Char[], Int32, Int32)
Declaration
public abstract override int Read(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | buffer | |
System.Int32 | index | |
System.Int32 | count |
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Reset()
LUCENENET specific. Moved here from the Reader class (in Java) so it can be overridden to provide reader buffering.
Declaration
public virtual void Reset()
Skip(Int32)
Skips characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.
LUCENENET specific. Moved here from the Reader class (in Java) so it can be overridden to provide reader buffering.
Declaration
public virtual long Skip(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | The number of characters to skip |
Returns
Type | Description |
---|---|
System.Int64 | The number of characters actually skipped |