Class StreamGobbler

  • All Implemented Interfaces:
    java.lang.Runnable

    public class StreamGobbler
    extends java.lang.Thread
    Read the contents of a stream in a separate thread This class is used when executing OS commands in order to read STDOUT / STDERR and prevent process blocking It can alert an AlertListener when a given string is in the stream
    Author:
    pcingola
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BUFFER_SIZE  
      static int HEAD_SIZE  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAlert()  
      java.lang.Object getAlertNotify()  
      java.lang.String getAllLines()  
      java.lang.String getHead()
      Head: First HEAD_SIZE lines of this output
      java.lang.String getRedirectTo()  
      boolean isAlertDone()  
      boolean isBinary()  
      boolean isRunning()  
      void resetBuffer()  
      void run()  
      void setAlert​(java.lang.String alert)  
      void setAlertNotify​(java.lang.Object alertNotify)  
      void setBinary​(boolean binary)  
      void setLineFilter​(LineFilter lineFilter)  
      void setProgress​(Progress progress)  
      void setQuietMode()  
      void setRedirectTo​(java.lang.String redirectTo)  
      void setSaveLinesInMemory​(boolean saveLinesInMemory)  
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • HEAD_SIZE

        public static int HEAD_SIZE
      • BUFFER_SIZE

        public static int BUFFER_SIZE
    • Method Detail

      • getAlert

        public java.lang.String getAlert()
      • getAlertNotify

        public java.lang.Object getAlertNotify()
      • getAllLines

        public java.lang.String getAllLines()
      • getHead

        public java.lang.String getHead()
        Head: First HEAD_SIZE lines of this output
        Returns:
      • getRedirectTo

        public java.lang.String getRedirectTo()
      • isAlertDone

        public boolean isAlertDone()
      • isBinary

        public boolean isBinary()
      • isRunning

        public boolean isRunning()
      • resetBuffer

        public void resetBuffer()
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • setAlert

        public void setAlert​(java.lang.String alert)
      • setAlertNotify

        public void setAlertNotify​(java.lang.Object alertNotify)
      • setBinary

        public void setBinary​(boolean binary)
      • setLineFilter

        public void setLineFilter​(LineFilter lineFilter)
      • setProgress

        public void setProgress​(Progress progress)
      • setQuietMode

        public void setQuietMode()
      • setRedirectTo

        public void setRedirectTo​(java.lang.String redirectTo)
      • setSaveLinesInMemory

        public void setSaveLinesInMemory​(boolean saveLinesInMemory)