Class CodeReaderFilter<O>

  • Direct Known Subclasses:
    ChannelCodeReaderFilter

    public abstract class CodeReaderFilter<O>
    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.
    • Constructor Detail

      • CodeReaderFilter

        public CodeReaderFilter()
      • CodeReaderFilter

        public CodeReaderFilter​(O 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 O getOutput()
        Returns the output object.
        Returns:
        the output
      • setOutput

        public void setOutput​(O 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:
        • 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.
        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