jfreerails.util
Class FlowRateInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by jfreerails.util.FlowRateInputStream
All Implemented Interfaces:
java.io.Closeable, java.lang.Runnable

public class FlowRateInputStream
extends java.io.FilterInputStream
implements java.lang.Runnable

A FilterInputStream that measures flow rate.

Author:
Patrice Espie Licensing: LGPL

Field Summary
private  long[] byteReceived
           
private  long byteReceivedCumul
           
private  boolean closeRequested
           
private  java.text.DecimalFormat decimalFormat
           
private static java.util.logging.Logger logger
           
private  long measureIntervall
           
private  int nbUsed
           
private  int nextFree
           
private  long openTimeMillis
           
private  long previousTotalByteReceived
           
private  boolean running
           
private  boolean showTrace
           
private  java.lang.String streamName
           
private  long totalByteReceived
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
FlowRateInputStream(java.io.InputStream in)
           
FlowRateInputStream(java.io.InputStream in, java.lang.String streamName)
           
FlowRateInputStream(java.io.InputStream in, java.lang.String streamName, int measureDuration, int measureInterval)
           
 
Method Summary
 void close()
           
 int currentRate()
           
 java.lang.String currentRateString()
           
 int overallRate()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void run()
           
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

byteReceived

private long[] byteReceived

byteReceivedCumul

private long byteReceivedCumul

totalByteReceived

private long totalByteReceived

previousTotalByteReceived

private long previousTotalByteReceived

openTimeMillis

private long openTimeMillis

measureIntervall

private long measureIntervall

nextFree

private int nextFree

nbUsed

private int nbUsed

running

private boolean running

closeRequested

private boolean closeRequested

streamName

private java.lang.String streamName

showTrace

private boolean showTrace

decimalFormat

private java.text.DecimalFormat decimalFormat
Constructor Detail

FlowRateInputStream

public FlowRateInputStream(java.io.InputStream in,
                           java.lang.String streamName)

FlowRateInputStream

public FlowRateInputStream(java.io.InputStream in,
                           java.lang.String streamName,
                           int measureDuration,
                           int measureInterval)

FlowRateInputStream

public FlowRateInputStream(java.io.InputStream in)
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

currentRate

public int currentRate()

currentRateString

public java.lang.String currentRateString()

overallRate

public int overallRate()

run

public void run()
Specified by:
run in interface java.lang.Runnable