Package org.sonar.sslr.channel
Class ChannelCodeReaderFilter<O>
- java.lang.Object
-
- org.sonar.sslr.channel.CodeReaderFilter<O>
-
- org.sonar.sslr.channel.ChannelCodeReaderFilter<O>
-
public final class ChannelCodeReaderFilter<O> extends CodeReaderFilter<O>
This class is a special CodeReaderFilter that uses Channels to filter the character stream before it is passed to the main channels declared for the CodeReader.
-
-
Constructor Summary
Constructors Constructor Description ChannelCodeReaderFilter(Channel<O>... channels)
Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader.ChannelCodeReaderFilter(O output, Channel<O>... channels)
Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
read(char[] filteredBuffer, int offset, int length)
This method implements the filtering logic, that is: get the characters from the reader, filter the character flow (and grab more characters from the reader if the filtering removes some), and fill the given buffer to its full capacity with the filtered data.void
setReader(Reader reader)
Sets the reader from which this class will read the character stream.-
Methods inherited from class org.sonar.sslr.channel.CodeReaderFilter
getConfiguration, getOutput, getReader, setConfiguration, setOutput
-
-
-
-
Constructor Detail
-
ChannelCodeReaderFilter
public ChannelCodeReaderFilter(Channel<O>... channels)
Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader.- Parameters:
channels
- the different channels
-
ChannelCodeReaderFilter
public ChannelCodeReaderFilter(O output, Channel<O>... channels)
Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader. And optionally, it can push token to the provided output object.- Parameters:
output
- the object that may accept tokenschannels
- the different channels
-
-
Method Detail
-
setReader
public void setReader(Reader reader)
Sets the reader from which this class will read the character stream.- Overrides:
setReader
in classCodeReaderFilter<O>
- Parameters:
reader
- the reader
-
read
public int read(char[] filteredBuffer, int offset, int length) throws IOException
This method implements the filtering logic, that is:- get the characters from the reader,
- filter the character flow (and grab more characters from the reader if the filtering removes some),
- and fill the given buffer to its full capacity with the filtered data.
- Specified by:
read
in classCodeReaderFilter<O>
- Parameters:
filteredBuffer
- the output buffer that must contain the filtered dataoffset
- the offset to start reading from the readerlength
- the number of characters to read from the reader- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
IOException
- If an I/O error occurs
-
-