Class InputStreamLineListener

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

public abstract class InputStreamLineListener extends Object implements IInputStreamListener
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.
Author:
Pascal Essiembre
See Also:
  • Constructor Details

    • InputStreamLineListener

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

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

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

    • streamed

      public void streamed(String type, byte[] bytes, int length)
      Description copied from interface: IInputStreamListener
      Invoked when a chunk of bytes is streamed.
      Specified by:
      streamed in interface IInputStreamListener
      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