cz.cuni.amis.utils
Class StreamSink

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

public class StreamSink
extends 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
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  Logger log
           
protected  String logId
           
protected  Level logLevel
           
protected  InputStream os
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamSink(String name, InputStream os)
          Constructs the sink to silently discard all contents of 'os'.
StreamSink(String name, InputStream os, Logger log)
          Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default.
StreamSink(String name, InputStream os, Logger log, String logId)
          Constructs the sink to redirect all output from 'os' into 'log' (used log level is Level.INFO) as default.
 
Method Summary
 Logger getLog()
           
 String getLogId()
           
 Level getLogLevel()
           
protected  void handleInput(String str)
           
 void run()
           
protected  StreamSink setLog(Logger log)
           
protected  StreamSink setLogId(String logId)
           
 StreamSink setLogLevel(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 InputStream os

log

protected Logger log

logId

protected String logId

logLevel

protected Level logLevel
Constructor Detail

StreamSink

public StreamSink(String name,
                  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(String name,
                  InputStream os,
                  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(String name,
                  InputStream os,
                  Logger log,
                  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 Level getLogLevel()

setLogLevel

public StreamSink setLogLevel(Level logLevel)

getLog

public Logger getLog()

setLog

protected StreamSink setLog(Logger log)

getLogId

public String getLogId()

setLogId

protected StreamSink setLogId(String logId)

handleInput

protected void handleInput(String str)

run

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


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.