Package groovy.ui

Class SystemOutputInterceptor

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
groovy.ui.SystemOutputInterceptor
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

@Deprecated
public class SystemOutputInterceptor
extends java.io.FilterOutputStream
Deprecated.
Intercepts System.out/System.err. Implementation helper for Console.groovy.
  • Field Summary

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors
    Constructor Description
    SystemOutputInterceptor​(Closure callback)
    Deprecated.
    Constructor
    SystemOutputInterceptor​(Closure callback, boolean output)
    Deprecated.
    Constructor
  • Method Summary

    Modifier and Type Method Description
    void removeConsoleId()
    Deprecated.
    Threads executing a script should call this method after execution completes in order to unregister the consoleId.
    void setConsoleId​(int consoleId)
    Deprecated.
    Threads executing a script should call this method at the start of execution in order to set the id of the console that is hosting the thread of execution.
    void start()
    Deprecated.
    Starts intercepting System.out/System.err
    void stop()
    Deprecated.
    Stops intercepting System.out/System.err, sending output to wherever it was going when this interceptor was created.
    void write​(byte[] b, int off, int len)
    Deprecated.
    Intercepts output - more common case of byte[]
    void write​(int b)
    Deprecated.
    Intercepts output - single characters

    Methods inherited from class java.io.FilterOutputStream

    close, flush, write

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SystemOutputInterceptor

      public SystemOutputInterceptor​(Closure callback)
      Deprecated.
      Constructor
      Parameters:
      callback - accepts the id of the target Console instance and a string to be sent to std out and returns a Boolean. If the return value is true, output will be sent to System.out, otherwise it will not.
    • SystemOutputInterceptor

      public SystemOutputInterceptor​(Closure callback, boolean output)
      Deprecated.
      Constructor
      Parameters:
      callback - accepts the id of the target Console instance and a string to be sent to std out and returns a Boolean. If the return value is true, output will be sent to System.out/System.err, otherwise it will not.
      output - flag that tells whether System.out needs capturing ot System.err
  • Method Details

    • start

      public void start()
      Deprecated.
      Starts intercepting System.out/System.err
    • stop

      public void stop()
      Deprecated.
      Stops intercepting System.out/System.err, sending output to wherever it was going when this interceptor was created.
    • write

      public void write​(byte[] b, int off, int len) throws java.io.IOException
      Deprecated.
      Intercepts output - more common case of byte[]
      Overrides:
      write in class java.io.FilterOutputStream
      Throws:
      java.io.IOException
    • write

      public void write​(int b) throws java.io.IOException
      Deprecated.
      Intercepts output - single characters
      Overrides:
      write in class java.io.FilterOutputStream
      Throws:
      java.io.IOException
    • setConsoleId

      public void setConsoleId​(int consoleId)
      Deprecated.
      Threads executing a script should call this method at the start of execution in order to set the id of the console that is hosting the thread of execution. This should be called prior to any output that is generated. The consoleId will be passed to the callback.
      Parameters:
      consoleId - id of the Console instance executing the script
    • removeConsoleId

      public void removeConsoleId()
      Deprecated.
      Threads executing a script should call this method after execution completes in order to unregister the consoleId.