sk.baka.ambient
Class NotifyingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by sk.baka.ambient.commons.CountingInputStream
          extended by sk.baka.ambient.NotifyingInputStream
All Implemented Interfaces:
Closeable

public class NotifyingInputStream
extends CountingInputStream

Notifies periodically the BackgroundOpExecutor about its progress.

Author:
Martin Vysny

Field Summary
 
Fields inherited from class sk.baka.ambient.commons.CountingInputStream
blockLength
 
Constructor Summary
NotifyingInputStream(InputStream in, int length, int parts, String caption)
           
 
Method Summary
protected  void countEvent(long currentPosition)
          Invoked when the position
static InputStream fromURL(URL url, int parts, String caption)
          Creates an input stream from given URL.
 
Methods inherited from class sk.baka.ambient.commons.CountingInputStream
available, close, getCurrentPosition, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotifyingInputStream

public NotifyingInputStream(InputStream in,
                            int length,
                            int parts,
                            String caption)
Parameters:
in - input stream
length - the length of the content.
parts - reports the progress parts times.
caption - the caption to set.
Method Detail

fromURL

public static InputStream fromURL(URL url,
                                  int parts,
                                  String caption)
                           throws IOException
Creates an input stream from given URL. If the url fails to supply content length then a simple buffered input stream is returned.

Parameters:
url - the URL to open.
parts - reports the progress parts times.
caption - the caption to set.
Returns:
the stream instance.
Throws:
IOException

countEvent

protected void countEvent(long currentPosition)
Description copied from class: CountingInputStream
Invoked when the position

Specified by:
countEvent in class CountingInputStream


Copyright © 2007-2008. All Rights Reserved.