Brooklyn

brooklyn.util.stream
[Java] Class ThreadLocalPrintStream

java.lang.Object
  java.io.OutputStream
      java.io.FilterOutputStream
          java.io.PrintStream
              brooklyn.util.stream.DelegatingPrintStream
                  brooklyn.util.stream.ThreadLocalPrintStream

public class ThreadLocalPrintStream
extends DelegatingPrintStream

Nested Class Summary
static class ThreadLocalPrintStream.OutputCapturingContext

 
Field Summary
protected java.lang.ThreadLocal customStream

protected java.io.PrintStream defaultPrintStream

 
Constructor Summary
ThreadLocalPrintStream(java.io.PrintStream defaultPrintStream)

 
Method Summary
ThreadLocalPrintStream.OutputCapturingContext capture()

creates a capturing context which eats the output to this stream, blocking the original target

ThreadLocalPrintStream.OutputCapturingContext captureTee()

creates a capturing context which sees the output to this stream, without interrupting the original target

java.io.PrintStream clearThreadLocalPrintStream()

java.io.PrintStream getDelegate()

java.io.PrintStream setThreadLocalPrintStream(java.io.OutputStream stream)

sets the PrintStream that callers from this thread should see; returns any previously custom PrintStream for this thread

static ThreadLocalPrintStream stderr()

installs a thread local print stream to System.err if one is not already set; caller may then #capture and #captureTee on it.

static ThreadLocalPrintStream stdout()

installs a thread local print stream to System.out if one is not already set; caller may then #capture and #captureTee on it.

 
Methods inherited from class DelegatingPrintStream
append, append, append, checkError, close, equals, flush, format, format, getDelegate, hashCode, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, toString, write, write, write
 
Methods inherited from class java.io.PrintStream
java.io.PrintStream#println(char), java.io.PrintStream#println(), java.io.PrintStream#println(boolean), java.io.PrintStream#println(java.lang.Object), java.io.PrintStream#println(java.lang.String), java.io.PrintStream#println([C), java.io.PrintStream#println(double), java.io.PrintStream#println(float), java.io.PrintStream#println(long), java.io.PrintStream#println(int), java.io.PrintStream#append(java.lang.CharSequence), java.io.PrintStream#append(java.lang.CharSequence), java.io.PrintStream#append(java.lang.CharSequence, int, int), java.io.PrintStream#append(char), java.io.PrintStream#append(char), java.io.PrintStream#append(java.lang.CharSequence, int, int), java.io.PrintStream#format(java.util.Locale, java.lang.String, [Ljava.lang.Object;), java.io.PrintStream#format(java.lang.String, [Ljava.lang.Object;), java.io.PrintStream#write([B, int, int), java.io.PrintStream#write(int), java.io.PrintStream#print(float), java.io.PrintStream#print(double), java.io.PrintStream#print([C), java.io.PrintStream#print(java.lang.String), java.io.PrintStream#print(java.lang.Object), java.io.PrintStream#print(boolean), java.io.PrintStream#print(char), java.io.PrintStream#print(int), java.io.PrintStream#print(long), java.io.PrintStream#flush(), java.io.PrintStream#close(), java.io.PrintStream#checkError(), java.io.PrintStream#printf(java.lang.String, [Ljava.lang.Object;), java.io.PrintStream#printf(java.util.Locale, java.lang.String, [Ljava.lang.Object;), java.io.PrintStream#write([B), java.io.PrintStream#wait(), java.io.PrintStream#wait(long), java.io.PrintStream#wait(long, int), java.io.PrintStream#equals(java.lang.Object), java.io.PrintStream#toString(), java.io.PrintStream#hashCode(), java.io.PrintStream#getClass(), java.io.PrintStream#notify(), java.io.PrintStream#notifyAll()
 

Field Detail

customStream

protected final java.lang.ThreadLocal customStream


defaultPrintStream

protected java.io.PrintStream defaultPrintStream


 
Constructor Detail

ThreadLocalPrintStream

public ThreadLocalPrintStream(java.io.PrintStream defaultPrintStream)


 
Method Detail

capture

public ThreadLocalPrintStream.OutputCapturingContext capture()
creates a capturing context which eats the output to this stream, blocking the original target


captureTee

public ThreadLocalPrintStream.OutputCapturingContext captureTee()
creates a capturing context which sees the output to this stream, without interrupting the original target


clearThreadLocalPrintStream

public java.io.PrintStream clearThreadLocalPrintStream()


getDelegate

@Override
public java.io.PrintStream getDelegate()


setThreadLocalPrintStream

public java.io.PrintStream setThreadLocalPrintStream(java.io.OutputStream stream)
sets the PrintStream that callers from this thread should see; returns any previously custom PrintStream for this thread


stderr

public static ThreadLocalPrintStream stderr()
installs a thread local print stream to System.err if one is not already set; caller may then #capture and #captureTee on it.
Returns:
the ThreadLocalPrintStream which System.err is using


stdout

public static ThreadLocalPrintStream stdout()
installs a thread local print stream to System.out if one is not already set; caller may then #capture and #captureTee on it.
Returns:
the ThreadLocalPrintStream which System.out is using


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.