org.jboss.util.stream
Class NotifyingBufferedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by org.jboss.util.stream.NotifyingBufferedInputStream
All Implemented Interfaces:
Closeable

public class NotifyingBufferedInputStream
extends BufferedInputStream

A buffered input stream that notifies every "chunk"

Version:
$Revision: 1.2.6.1 $
Author:
Adrian Brock

Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
NotifyingBufferedInputStream(InputStream is, int size, int chunkSize, StreamListener listener)
          Construct a notifying buffered inputstream.
 
Method Summary
 void checkNotification(int result)
          Checks whether a notification is required and notifies as appropriate
 int read()
           
 int read(byte[] b, int off, int len)
           
 void setStreamListener(StreamListener listener)
           
 
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotifyingBufferedInputStream

public NotifyingBufferedInputStream(InputStream is,
                                    int size,
                                    int chunkSize,
                                    StreamListener listener)
Construct a notifying buffered inputstream. The listener is notified once every chunk.

Parameters:
is - the input stream to be buffered
size - the buffer size
chunkSize - the chunk size
listener - the listener to notify
Throws:
IllegalArgumentException - for a size <= 0 or chunkSize <= size
Method Detail

setStreamListener

public void setStreamListener(StreamListener listener)

read

public int read()
         throws IOException
Overrides:
read in class BufferedInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class BufferedInputStream
Throws:
IOException

checkNotification

public void checkNotification(int result)
Checks whether a notification is required and notifies as appropriate

Parameters:
result - the number of bytes read


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.