org.aspectj.util
Class FileUtil.Pipe

java.lang.Object
  extended by org.aspectj.util.FileUtil.Pipe
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
FileUtil

public static class FileUtil.Pipe
extends java.lang.Object
implements java.lang.Runnable

A pipe when run reads from an input stream to an output stream, optionally sleeping between reads.

See Also:
FileUtil.copyStream(InputStream, OutputStream)

Method Summary
protected  void completing(long totalWritten, java.lang.Throwable thrown)
          This is called when the pipe is completing.
 java.lang.Throwable getThrown()
           
 boolean halt(boolean wait, boolean finishStream)
          Tell the pipe to halt the next time it gains control.
 void run()
          Run the pipe.
 void setSnoop(java.io.ByteArrayOutputStream snoop)
           
 long totalWritten()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setSnoop

public void setSnoop(java.io.ByteArrayOutputStream snoop)

run

public void run()
Run the pipe. This halts on the first Throwable thrown or when a read returns -1 (for end-of-file) or on demand.

Specified by:
run in interface java.lang.Runnable

halt

public boolean halt(boolean wait,
                    boolean finishStream)
Tell the pipe to halt the next time it gains control.

Parameters:
wait - if true, this waits synchronously until pipe is done
finishStream - if true, then continue until a read from the input stream returns no bytes, then halt.
Returns:
true if run() will return the next time it gains control

totalWritten

public long totalWritten()
Returns:
the total number of bytes written

getThrown

public java.lang.Throwable getThrown()
Returns:
any exception thrown when reading/writing

completing

protected void completing(long totalWritten,
                          java.lang.Throwable thrown)
This is called when the pipe is completing. This implementation does nothing. Subclasses implement this to get notice. Note that halt(true, true) might or might not have completed before this method is called.