Class 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 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 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<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 class CodeReaderFilter<O>
        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