Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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.
    Inheritance
    object
    MarshalByRefObject
    TextReader
    CharFilter
    Implements
    IDisposable
    Inherited Members
    TextReader.Null
    TextReader.Close()
    TextReader.Dispose()
    TextReader.Peek()
    TextReader.Read(Span<char>)
    TextReader.ReadAsync(char[], int, int)
    TextReader.ReadAsync(Memory<char>, CancellationToken)
    TextReader.ReadBlock(char[], int, int)
    TextReader.ReadBlock(Span<char>)
    TextReader.ReadBlockAsync(char[], int, int)
    TextReader.ReadBlockAsync(Memory<char>, CancellationToken)
    TextReader.ReadLine()
    TextReader.ReadLineAsync()
    TextReader.ReadLineAsync(CancellationToken)
    TextReader.ReadToEnd()
    TextReader.ReadToEndAsync()
    TextReader.ReadToEndAsync(CancellationToken)
    TextReader.Synchronized(TextReader)
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    MarshalByRefObject.MemberwiseClone(bool)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 call base.Dispose(disposing) when overriding this method.
    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    TextReader.Dispose(bool)

    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
    TextReader.Read()
    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 index and (index + count - 1) replaced by the characters read from the current source.

    int index

    The position in buffer at which to begin writing.

    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 count, depending on whether the data is available within the reader. This method returns 0 (zero) if it is called when no more characters are left to read.

    Overrides
    TextReader.Read(char[], int, int)
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null.

    ArgumentException

    The buffer length minus index is less than count.

    ArgumentOutOfRangeException

    index or count is negative.

    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

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.