public class SystemOutputInterceptor extends FilterOutputStream
out
Constructor and Description |
---|
SystemOutputInterceptor(Closure callback)
Constructor
|
SystemOutputInterceptor(Closure callback,
boolean output)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
removeConsoleId()
Threads executing a script should call this method after
execution completes in order to unregister the consoleId.
|
void |
setConsoleId(int consoleId)
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()
Starts intercepting System.out/System.err
|
void |
stop()
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)
Intercepts output - more common case of byte[]
|
void |
write(int b)
Intercepts output - single characters
|
close, flush, write
public SystemOutputInterceptor(Closure callback)
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.public SystemOutputInterceptor(Closure callback, boolean output)
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.errpublic void start()
public void stop()
public void write(byte[] b, int off, int len) throws IOException
write
in class FilterOutputStream
IOException
public void write(int b) throws IOException
write
in class FilterOutputStream
IOException
public void setConsoleId(int consoleId)
consoleId
- id of the Console instance executing the scriptpublic void removeConsoleId()