org.ops4j.io
Class PrintStreamMonitor

java.lang.Object
  extended by org.ops4j.io.PrintStreamMonitor
All Implemented Interfaces:
StreamMonitor

public class PrintStreamMonitor
extends java.lang.Object
implements StreamMonitor

PrintStreamMonitor is a convenience implementation of the StreamMonitor for output to a PrintStream, such as System.out.

Example of usage;


      StreamMonitor monitor = new PrintStreamMonitor( System.out );
      StreamUtils.copyStream( monitor, sourceURL, length, srcStream, destStream, true );
 


Constructor Summary
PrintStreamMonitor(java.io.PrintStream out)
           
 
Method Summary
 void notifyCompletion(java.net.URL resource)
          Notify the monitor of the successful completion of a download process.
 void notifyError(java.net.URL resource, java.lang.String message)
          Notify the monitor of the an error during the download process.
 void notifyUpdate(java.net.URL resource, int expected, int count)
          Notify the monitor of the update in the download status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintStreamMonitor

public PrintStreamMonitor(java.io.PrintStream out)
Parameters:
out - The PrintStream that should receive the monitored output.
Method Detail

notifyUpdate

public void notifyUpdate(java.net.URL resource,
                         int expected,
                         int count)
Notify the monitor of the update in the download status.

Specified by:
notifyUpdate in interface StreamMonitor
Parameters:
resource - the name of the remote resource being downloaded.
expected - the expected number of bytes to be downloaded.
count - the number of bytes downloaded.

notifyCompletion

public void notifyCompletion(java.net.URL resource)
Notify the monitor of the successful completion of a download process.

Specified by:
notifyCompletion in interface StreamMonitor
Parameters:
resource - the name of the remote resource.

notifyError

public void notifyError(java.net.URL resource,
                        java.lang.String message)
Notify the monitor of the an error during the download process.

Specified by:
notifyError in interface StreamMonitor
Parameters:
resource - the name of the remote resource.
message - a non-localized message describing the problem in english.


Copyright © 2006-2008 OPS4J - Open Participation Software for Java. All Rights Reserved.