Class InputStreamLineListener

java.lang.Object
com.norconex.commons.lang.io.InputStreamLineListener
All Implemented Interfaces:
InputStreamListener

public abstract class InputStreamLineListener extends Object implements InputStreamListener
Listener that is being notified every time a line is processed from a given stream. Not thread-safe. Use a new instance for each thread or at a minimum, make sure to give a unique type argument to each InputStreamConsumer to prevent lines content being mixed up.
See Also:
  • Constructor Details

    • InputStreamLineListener

      protected InputStreamLineListener()
      Creates a line listener with UTF-8 character encoding.
    • InputStreamLineListener

      protected InputStreamLineListener(Charset charset)
      Creates a line listener with supplied character encoding (defaults to UTF-8 if null).
      Parameters:
      charset - character encoding
    • InputStreamLineListener

      protected InputStreamLineListener(String charset)
      Creates a line listener with supplied character encoding (defaults to UTF-8 if null).
      Parameters:
      charset - character encoding
  • Method Details

    • getCharset

      protected Charset getCharset()
      Gets the character encoding this listener is expected to receive.
      Returns:
      character encoding
      Since:
      3.0.0
    • streamed

      public void streamed(String type, byte[] bytes, int length)
      Description copied from interface: InputStreamListener
      Invoked when a chunk of bytes is streamed.
      Specified by:
      streamed in interface InputStreamListener
      Parameters:
      type - type of what is being streamed, as defined by the class using this listener
      bytes - chunk of bytes streamed
      length - length of valid bytes to read or -1 if no more bytes to read
    • lineStreamed

      protected abstract void lineStreamed(String type, String line)
      Invoked when a line is streamed.
      Parameters:
      type - type of line, as defined by the class using the listener
      line - line processed