org.sonar.channel
Class ChannelCodeReaderFilter<OUTPUT>

java.lang.Object
  extended by org.sonar.channel.CodeReaderFilter<OUTPUT>
      extended by org.sonar.channel.ChannelCodeReaderFilter<OUTPUT>

public final class ChannelCodeReaderFilter<OUTPUT>
extends CodeReaderFilter<OUTPUT>

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
ChannelCodeReaderFilter(Channel<OUTPUT>... channels)
          Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader.
ChannelCodeReaderFilter(OUTPUT output, Channel<OUTPUT>... channels)
          Creates a CodeReaderFilter that will use the provided Channels to filter the character stream it gets from its reader.
 
Method Summary
 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.channel.CodeReaderFilter
getConfiguration, getOutput, getReader, setConfiguration, setOutput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelCodeReaderFilter

public ChannelCodeReaderFilter(Channel<OUTPUT>... 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(OUTPUT output,
                               Channel<OUTPUT>... 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 tokens
channels - 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 class CodeReaderFilter<OUTPUT>
Parameters:
reader - the reader

read

public int read(char[] filteredBuffer,
                int offset,
                int length)
         throws IOException
This method implements the filtering logic, that is:

Specified by:
read in class CodeReaderFilter<OUTPUT>
Parameters:
filteredBuffer - the output buffer that must contain the filtered data
offset - the offset to start reading from the reader
length - 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


Copyright © 2009-2011 SonarSource. All Rights Reserved.