Class CharFilter
Subclasses of CharFilter can be chained to filter a TextReader They can be used as TextReader with additional offset correction. Tokenizers will automatically use CorrectOffset(int) if a CharFilter subclass is used.
This class is abstract: at a minimum you must implement Read(char[], int, int), transforming the input in some way from m_input, and Correct(int) to adjust the offsets to match the originals. You can optionally provide more efficient implementations of additional methods like Read(), but this is not required. For examples and integration with Analyzer, see the Lucene.Net.Analysis namespace documentation.Implements
Inherited Members
Namespace: Lucene.Net.Analysis
Assembly: Lucene.Net.dll
Syntax
public abstract class CharFilter : TextReader, IDisposable
Constructors
CharFilter(TextReader)
Create a new CharFilter wrapping the provided reader.
Declaration
protected CharFilter(TextReader input)
Parameters
Type | Name | Description |
---|---|---|
TextReader | input | a TextReader, can also be a CharFilter for chaining. |
Fields
m_input
The underlying character-input stream.
Declaration
protected readonly TextReader m_input
Field Value
Type | Description |
---|---|
TextReader |
Properties
IsMarkSupported
Tells whether this stream supports the Mark(int) 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 |
---|---|
bool | 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 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 |
---|---|
bool |
Methods
Correct(int)
Subclasses override to correct the current offset.
Declaration
protected abstract int Correct(int currentOff)
Parameters
Type | Name | Description |
---|---|---|
int | currentOff | current offset |
Returns
Type | Description |
---|---|
int | corrected offset |
CorrectOffset(int)
Chains the corrected offset through the input CharFilter(s).
Declaration
public int CorrectOffset(int currentOff)
Parameters
Type | Name | Description |
---|---|---|
int | currentOff |
Returns
Type | Description |
---|---|
int |
Dispose(bool)
Closes the underlying input stream.
NOTE: The default implementation closes the input TextReader, so be sure to callbase.Dispose(disposing)
when overriding this method.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
Overrides
Mark(int)
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(int) 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 |
---|---|---|
int | 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()
Reads the next character from the text reader and advances the character position by one character.
Declaration
public override int Read()
Returns
Type | Description |
---|---|
int | The next character from the text reader, or -1 if no more characters are available. The default implementation returns -1. |
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The TextReader is closed. |
IOException | An I/O error occurs. |
Read(char[], int, int)
Reads a specified maximum number of characters from the current reader and writes the data to a buffer, beginning at the specified index.
Declaration
public override abstract int Read(char[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
char[] | buffer | When this method returns, contains the specified character array with the values between |
int | index | The position in |
int | count | The maximum number of characters to read. If the end of the reader is reached before the specified number of characters is read into the buffer, the method returns. |
Returns
Type | Description |
---|---|
int | The number of characters that have been read. The number will be less than or equal to |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException | The buffer length minus |
ArgumentOutOfRangeException |
|
ObjectDisposedException | The TextReader is closed. |
IOException | An I/O error occurs. |
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(int)
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 |
---|---|---|
int | n | The number of characters to skip |
Returns
Type | Description |
---|---|
long | The number of characters actually skipped |