cz.cuni.amis.utils
Class StreamSink

java.lang.Object
  extended by java.lang.Thread
      extended by cz.cuni.amis.utils.StreamSink
All Implemented Interfaces:
java.lang.Runnable

public class StreamSink
extends java.lang.Thread

Reads content of the stream and discards it.

Optionally it may log the content of the stream to some logger (i.e., redirects the output of the stream to some log).


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.util.logging.Logger log
           
protected  java.lang.String logId
           
protected  java.util.logging.Level logLevel
           
protected  java.io.InputStream os
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamSink(java.lang.String name, java.io.InputStream os)
          Constructs the sink to silently discard all contents of 'os'.
StreamSink(java.lang.String name, java.io.InputStream os, java.util.logging.Logger log)
          Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default.
StreamSink(java.lang.String name, java.io.InputStream os, java.util.logging.Logger log, java.lang.String logId)
          Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default.
 
Method Summary
 java.util.logging.Logger getLog()
           
 java.lang.String getLogId()
           
 java.util.logging.Level getLogLevel()
           
protected  void handleInput(java.lang.String str)
           
 void run()
           
protected  StreamSink setLog(java.util.logging.Logger log)
           
protected  StreamSink setLogId(java.lang.String logId)
           
 StreamSink setLogLevel(java.util.logging.Level logLevel)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

os

protected java.io.InputStream os

log

protected java.util.logging.Logger log

logId

protected java.lang.String logId

logLevel

protected java.util.logging.Level logLevel
Constructor Detail

StreamSink

public StreamSink(java.lang.String name,
                  java.io.InputStream os)
Constructs the sink to silently discard all contents of 'os'.

Parameters:
name - name of the sink thread
os - stream to be sunk

StreamSink

public StreamSink(java.lang.String name,
                  java.io.InputStream os,
                  java.util.logging.Logger log)
Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default. May be changed by setLogLevel(Level). May

Parameters:
name - name of the sink thread
os -
log -

StreamSink

public StreamSink(java.lang.String name,
                  java.io.InputStream os,
                  java.util.logging.Logger log,
                  java.lang.String logId)
Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default. May be changed by setLogLevel(Level). Additionally all messages from the 'os' will be prefixed with 'logId+" "'.

Parameters:
name - name of the sink thread
os -
log -
logId -
Method Detail

getLogLevel

public java.util.logging.Level getLogLevel()

setLogLevel

public StreamSink setLogLevel(java.util.logging.Level logLevel)

getLog

public java.util.logging.Logger getLog()

setLog

protected StreamSink setLog(java.util.logging.Logger log)

getLogId

public java.lang.String getLogId()

setLogId

protected StreamSink setLogId(java.lang.String logId)

handleInput

protected void handleInput(java.lang.String str)

run

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