org.sonar.channel
Class CodeReaderFilter<OUTPUT>

java.lang.Object
  extended by org.sonar.channel.CodeReaderFilter<OUTPUT>
Direct Known Subclasses:
ChannelCodeReaderFilter

public abstract class CodeReaderFilter<OUTPUT>
extends Object

This class can be extended to provide filtering capabilities for the CodeReader class.
The purpose is to filter the character flow before the CodeReader class passes it to the different channels. It is possible to give several filters to a CodeReader: they will be called one after another, following the declaration order in the CodeReader constructor, to sequentially filter the character flow.

See Also:
CodeReader, CodeBufferTest#testCodeReaderFilter(), CodeBufferTest#testSeveralCodeReaderFilter()

Constructor Summary
CodeReaderFilter()
           
CodeReaderFilter(OUTPUT output)
           
 
Method Summary
 CodeReaderConfiguration getConfiguration()
          Returns the configuration used for the CodeReader
 OUTPUT getOutput()
          Returns the output object.
 Reader getReader()
          Returns the reader from which this class reads the character stream.
abstract  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 setConfiguration(CodeReaderConfiguration configuration)
          Sets the configuration that must be used by the CodeReader
 void setOutput(OUTPUT output)
          Sets the output object
 void setReader(Reader reader)
          Sets the reader from which this class will read the character stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeReaderFilter

public CodeReaderFilter()

CodeReaderFilter

public CodeReaderFilter(OUTPUT output)
Method Detail

getReader

public Reader getReader()
Returns the reader from which this class reads the character stream.

Returns:
the reader

setReader

public void setReader(Reader reader)
Sets the reader from which this class will read the character stream.

Parameters:
reader - the reader

getOutput

public OUTPUT getOutput()
Returns the output object.

Returns:
the output

setOutput

public void setOutput(OUTPUT output)
Sets the output object

Parameters:
output - the output to set

getConfiguration

public CodeReaderConfiguration getConfiguration()
Returns the configuration used for the CodeReader

Returns:
the configuration

setConfiguration

public void setConfiguration(CodeReaderConfiguration configuration)
Sets the configuration that must be used by the CodeReader

Parameters:
configuration - the configuration to set

read

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

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-2012 SonarSource. All Rights Reserved.