From 0a09bb843c493d21c78a63dd30aee1c482faa619 Mon Sep 17 00:00:00 2001 From: bellingard Date: Thu, 14 Oct 2010 15:07:12 +0000 Subject: [PATCH] [SONAR-1853] Create a new CodeReaderFilter mechanism to prevent logic duplications between Channel(s) http://jira.codehaus.org/browse/SONAR-1853 Javadoc added --- .../org/sonar/channel/CodeReaderFilter.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/sonar-channel/src/main/java/org/sonar/channel/CodeReaderFilter.java b/sonar-channel/src/main/java/org/sonar/channel/CodeReaderFilter.java index e65136106b6..4c63bcd9f90 100644 --- a/sonar-channel/src/main/java/org/sonar/channel/CodeReaderFilter.java +++ b/sonar-channel/src/main/java/org/sonar/channel/CodeReaderFilter.java @@ -3,8 +3,42 @@ package org.sonar.channel; import java.io.IOException; import java.io.Reader; +/** + * 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 CodeReader + * @see CodeBufferTest#testCodeReaderFilter() + * @see CodeBufferTest#testSeveralCodeReaderFilter() + * + */ public abstract class CodeReaderFilter { - public abstract int read(Reader in, char[] cbuf, int off, int len) throws IOException; + /** + * This method implements the filtering logic, that is: + * + * + * @param reader + * the input character flow + * @param filteredBuffer + * the output buffer that must contain the filtered data + * @param offset + * the offset to start reading from the reader + * @param lenght + * the number of characters to read from the reader + * @return The number of characters read, or -1 if the end of the stream has been reached + * @throws IOException + * If an I/O error occurs + */ + public abstract int read(Reader reader, char[] filteredBuffer, int offset, int lenght) throws IOException; } -- 2.39.5