Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class BufferedCharFilter

    LUCENENET specific class to mimic Java's BufferedReader (that is, a reader that is seekable) so it supports Mark() and Reset() (which are part of the Java Reader class), but also provide the Correct() method of BaseCharFilter.

    Inheritance
    object
    MarshalByRefObject
    TextReader
    CharFilter
    BaseCharFilter
    BufferedCharFilter
    Implements
    IDisposable
    Inherited Members
    BaseCharFilter.Correct(int)
    BaseCharFilter.LastCumulativeDiff
    BaseCharFilter.AddOffCorrectMap(int, int)
    CharFilter.m_input
    CharFilter.CorrectOffset(int)
    TextReader.Null
    TextReader.Dispose()
    TextReader.ReadLineAsync(CancellationToken)
    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.Util
    Assembly: Lucene.Net.Analysis.Common.dll
    Syntax
    public class BufferedCharFilter : BaseCharFilter, IDisposable

    Constructors

    BufferedCharFilter(TextReader)

    Creates a buffering character-input stream that uses a default-sized input buffer.

    Declaration
    public BufferedCharFilter(TextReader @in)
    Parameters
    Type Name Description
    TextReader in

    A TextReader

    BufferedCharFilter(TextReader, int)

    Creates a buffering character-input stream that uses an input buffer of the specified size.

    Declaration
    public BufferedCharFilter(TextReader @in, int size)
    Parameters
    Type Name Description
    TextReader in

    A TextReader

    int size

    Input-buffer size

    Fields

    DEFAULT_CHAR_BUFFER_SIZE

    LUCENENET specific class to mimic Java's BufferedReader (that is, a reader that is seekable) so it supports Mark() and Reset() (which are part of the Java Reader class), but also provide the Correct() method of BaseCharFilter.

    Declaration
    public const int DEFAULT_CHAR_BUFFER_SIZE = 8192
    Field Value
    Type Description
    int

    m_lock

    The object used to synchronize access to the reader.

    Declaration
    protected object m_lock
    Field Value
    Type Description
    object

    Properties

    IsMarkSupported

    Indicates whether this reader supports the Mark(int) and Reset() methods. This implementation returns true.

    Declaration
    public override bool IsMarkSupported { get; }
    Property Value
    Type Description
    bool
    Overrides
    Lucene.Net.Analysis.CharFilter.IsMarkSupported
    See Also
    Mark(int)
    Reset()

    IsReady

    Indicates whether this reader is ready to be read without blocking.

    Declaration
    public override bool IsReady { get; }
    Property Value
    Type Description
    bool

    true if this reader will not block when Read() is called, false if unknown or blocking will occur.

    Overrides
    Lucene.Net.Analysis.CharFilter.IsReady

    Methods

    Close()

    Not supported.

    Declaration
    public override void Close()
    Overrides
    TextReader.Close()
    Exceptions
    Type Condition
    NotSupportedException

    The call didn't originate from within Dispose(bool).

    Dispose(bool)

    Disposes this reader. This implementation closes the buffered source reader and releases the buffer. Nothing is done if this reader has already been disposed.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    CharFilter.Dispose(bool)
    Exceptions
    Type Condition
    IOException

    if an error occurs while closing this reader.

    Mark(int)

    Sets a mark position in this reader. The parameter markLimit indicates how many characters can be read before the mark is invalidated. Calling Reset() will reposition the reader back to the marked position if markLimit has not been surpassed.

    Declaration
    public override void Mark(int markLimit)
    Parameters
    Type Name Description
    int markLimit

    the number of characters that can be read before the mark is invalidated.

    Overrides
    CharFilter.Mark(int)
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    if markLimit < 0

    IOException

    if an error occurs while setting a mark in this reader.

    Peek()

    Reads a single character from this reader and returns it with the two higher-order bytes set to 0. If possible, BufferedCharFilter returns a character from the buffer. If there are no characters available in the buffer, it fills the buffer and then returns a character. It returns -1 if there are no more characters in the source reader. Unlike Read(), this method does not advance the current position.

    Declaration
    public override int Peek()
    Returns
    Type Description
    int

    The character read or -1 if the end of the source reader has been reached.

    Overrides
    TextReader.Peek()
    Exceptions
    Type Condition
    IOException

    If this reader is disposed or some other I/O error occurs.

    Read()

    Reads a single character from this reader and returns it with the two higher-order bytes set to 0. If possible, BufferedCharFilter returns a character from the buffer. If there are no characters available in the buffer, it fills the buffer and then returns a character. It returns -1 if there are no more characters in the source reader.

    Declaration
    public override int Read()
    Returns
    Type Description
    int

    The character read or -1 if the end of the source reader has been reached.

    Overrides
    Lucene.Net.Analysis.CharFilter.Read()
    Exceptions
    Type Condition
    IOException

    If this reader is disposed or some other I/O error occurs.

    Read(char[], int, int)

    Reads at most length characters from this reader and stores them at offset in the character array buffer. Returns the number of characters actually read or -1 if the end of the source reader has been reached. If all the buffered characters have been used, a mark has not been set and the requested number of characters is larger than this readers buffer size, BufferedReader bypasses the buffer and simply places the results directly into buffer.

    Declaration
    public override int Read(char[] buffer, int offset, int length)
    Parameters
    Type Name Description
    char[] buffer

    the character array to store the characters read.

    int offset

    the initial position in buffer to store the bytes read from this reader.

    int length

    the maximum number of characters to read, must be non-negative.

    Returns
    Type Description
    int

    number of characters read or -1 if the end of the source reader has been reached.

    Overrides
    CharFilter.Read(char[], int, int)
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    if offset < 0 or length < 0, or if offset + length is greater than the size of buffer.

    IOException

    if this reader is disposed or some other I/O error occurs.

    Read(Span<char>)

    Not supported.

    Declaration
    public override int Read(Span<char> buffer)
    Parameters
    Type Name Description
    Span<char> buffer
    Returns
    Type Description
    int
    Overrides
    TextReader.Read(Span<char>)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadAsync(char[], int, int)

    Not supported.

    Declaration
    public override Task<int> ReadAsync(char[] buffer, int index, int count)
    Parameters
    Type Name Description
    char[] buffer
    int index
    int count
    Returns
    Type Description
    Task<int>
    Overrides
    TextReader.ReadAsync(char[], int, int)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadAsync(Memory<char>, CancellationToken)

    Not supported.

    Declaration
    public override ValueTask<int> ReadAsync(Memory<char> buffer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Memory<char> buffer
    CancellationToken cancellationToken
    Returns
    Type Description
    ValueTask<int>
    Overrides
    TextReader.ReadAsync(Memory<char>, CancellationToken)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadBlock(char[], int, int)

    Not supported.

    Declaration
    public override int ReadBlock(char[] buffer, int index, int count)
    Parameters
    Type Name Description
    char[] buffer
    int index
    int count
    Returns
    Type Description
    int
    Overrides
    TextReader.ReadBlock(char[], int, int)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadBlock(Span<char>)

    Not supported.

    Declaration
    public override int ReadBlock(Span<char> buffer)
    Parameters
    Type Name Description
    Span<char> buffer
    Returns
    Type Description
    int
    Overrides
    TextReader.ReadBlock(Span<char>)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadBlockAsync(char[], int, int)

    Not supported.

    Declaration
    public override Task<int> ReadBlockAsync(char[] buffer, int index, int count)
    Parameters
    Type Name Description
    char[] buffer
    int index
    int count
    Returns
    Type Description
    Task<int>
    Overrides
    TextReader.ReadBlockAsync(char[], int, int)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadBlockAsync(Memory<char>, CancellationToken)

    Not supported.

    Declaration
    public override ValueTask<int> ReadBlockAsync(Memory<char> buffer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Memory<char> buffer
    CancellationToken cancellationToken
    Returns
    Type Description
    ValueTask<int>
    Overrides
    TextReader.ReadBlockAsync(Memory<char>, CancellationToken)
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadLine()

    Returns the next line of text available from this reader. A line is represented by zero or more characters followed by '\n', '\r', "\r\n" or the end of the reader. The string does not include the newline sequence.

    Declaration
    public override string ReadLine()
    Returns
    Type Description
    string

    The contents of the line or null if no characters were read before the end of the reader has been reached.

    Overrides
    TextReader.ReadLine()
    Exceptions
    Type Condition
    IOException

    if this reader is disposed or some other I/O error occurs.

    ReadLineAsync()

    Not supported.

    Declaration
    public override Task<string> ReadLineAsync()
    Returns
    Type Description
    Task<string>
    Overrides
    TextReader.ReadLineAsync()
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadToEnd()

    Not supported.

    Declaration
    public override string ReadToEnd()
    Returns
    Type Description
    string
    Overrides
    TextReader.ReadToEnd()
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    ReadToEndAsync()

    Not supported.

    Declaration
    public override Task<string> ReadToEndAsync()
    Returns
    Type Description
    Task<string>
    Overrides
    TextReader.ReadToEndAsync()
    Exceptions
    Type Condition
    NotSupportedException

    In all cases.

    Reset()

    Resets this reader's position to the last Mark(int) location. Invocations of Read() and Skip(int) will occur from this new location.

    Declaration
    public override void Reset()
    Overrides
    Lucene.Net.Analysis.CharFilter.Reset()
    Exceptions
    Type Condition
    IOException

    If this reader is disposed or no mark has been set.

    See Also
    Mark(int)
    IsMarkSupported

    Skip(int)

    Skips amount characters in this reader. Subsequent Read()s will not return these characters unless Reset() is used. Skipping characters may invalidate a mark if markLimit is surpassed.

    Declaration
    public override long Skip(int amount)
    Parameters
    Type Name Description
    int amount

    the maximum number of characters to skip.

    Returns
    Type Description
    long

    the number of characters actually skipped.

    Overrides
    CharFilter.Skip(int)
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    if amount < 0.

    IOException

    If this reader is disposed or some other I/O error occurs.

    See Also
    Mark(int)
    IsMarkSupported
    Reset()

    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.