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.
Implements
Inherited Members
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
See Also
IsReady
Indicates whether this reader is ready to be read without blocking.
Declaration
public override bool IsReady { get; }
Property Value
Type | Description |
---|---|
bool |
|
Overrides
Methods
Close()
Not supported.
Declaration
public override void Close()
Overrides
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
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
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | if |
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
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
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 |
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
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | if |
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
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
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
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
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
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
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
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 |
Overrides
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
Exceptions
Type | Condition |
---|---|
NotSupportedException | In all cases. |
ReadToEnd()
Not supported.
Declaration
public override string ReadToEnd()
Returns
Type | Description |
---|---|
string |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | In all cases. |
ReadToEndAsync()
Not supported.
Declaration
public override Task<string> ReadToEndAsync()
Returns
Type | Description |
---|---|
Task<string> |
Overrides
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
Exceptions
Type | Condition |
---|---|
IOException | If this reader is disposed or no mark has been set. |
See Also
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
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | if |
IOException | If this reader is disposed or some other I/O error occurs. |