com.jalios.io
Class MonitoredInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by com.jalios.io.MonitoredInputStream
All Implemented Interfaces:
Closeable

public class MonitoredInputStream
extends BufferedInputStream

A BufferedInputStream that count bytes read to display the status of the stream.

Version:
$Revision: 27751 $
Author:
Jean-Philippe

Field Summary
protected  long maxlength
           
protected  long readlength
           
static String REVISION
           
protected  long startingTime
           
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MonitoredInputStream(InputStream stream, int size, long maxlength)
           
 
Method Summary
 long getSpentTime(boolean elapse)
          Return the time spent into this output stream
 long getStatus(boolean absolute, boolean done)
          Return the status of the stream.
 int read()
          Delegate Read to super class, count charactere read.
 int read(byte[] b, int off, int len)
          Delegate Read to super class, count charactere read.
 
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
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

maxlength

protected long maxlength

readlength

protected long readlength

startingTime

protected long startingTime
Constructor Detail

MonitoredInputStream

public MonitoredInputStream(InputStream stream,
                            int size,
                            long maxlength)
Method Detail

read

public int read()
         throws IOException
Delegate Read to super class, count charactere read.

Overrides:
read in class BufferedInputStream
Throws:
IOException
See Also:
InputStream.read()

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Delegate Read to super class, count charactere read.

Overrides:
read in class BufferedInputStream
Throws:
IOException
See Also:
InputStream.read(byte[], int, int)

getStatus

public long getStatus(boolean absolute,
                      boolean done)
Return the status of the stream. How many bytes have been read.

Parameters:
absolute - if return an absolute value or percentage
done - if return the available byte or done bytes
Returns:
long the status of the stream

getSpentTime

public long getSpentTime(boolean elapse)
Return the time spent into this output stream

Parameters:
elapse - true return time spent, false return time to spent
Returns:
the duration
Since:
jcms-4.2


Copyright © 2001-2010 Jalios SA. All Rights Reserved.