ParkNPark.tests
Class InputCopier

java.lang.Object
  extended by java.lang.Thread
      extended by ParkNPark.tests.InputCopier
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ClientInputCopier, ErrorCopier, ServerInputCopier

 class InputCopier
extends Thread

Copies lines from a Reader to a Writer, one line at a time, as a background Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  BufferedReader reader
           
protected  BufferedWriter writer
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
InputCopier(Reader reader, Writer writer)
           
 
Method Summary
protected  void closeReader()
          Called when the reader is ready to be closed
protected  void closeWriter()
          Called when the writer is ready to be closed
protected  void lineProcessed(String line)
          Called after a line has been written to the writer
protected  void processingFinished()
          Called when the processing finishes, just before the reader and writer are closed
protected  String processLine(String line)
          Processes the given line and returns the line that should be written to the writer or null if the copier should stop copying
 void run()
          Copies lines from the reader to the writer
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reader

protected BufferedReader reader

writer

protected BufferedWriter writer
Constructor Detail

InputCopier

public InputCopier(Reader reader,
                   Writer writer)
Method Detail

processLine

protected String processLine(String line)
Processes the given line and returns the line that should be written to the writer or null if the copier should stop copying

Parameters:
line - The line returned from the reader
Returns:
The line to write to the writer or null if the copier should stop copying

processingFinished

protected void processingFinished()
Called when the processing finishes, just before the reader and writer are closed


lineProcessed

protected void lineProcessed(String line)
Called after a line has been written to the writer

Parameters:
line - The line that was written to the writer

closeReader

protected void closeReader()
Called when the reader is ready to be closed


closeWriter

protected void closeWriter()
Called when the writer is ready to be closed


run

public void run()
Copies lines from the reader to the writer

Specified by:
run in interface Runnable
Overrides:
run in class Thread