jfreerails.util
Class FlowRateOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by jfreerails.util.FlowRateOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Runnable

public class FlowRateOutputStream
extends java.io.FilterOutputStream
implements java.lang.Runnable

A FilterOutputStream that measures flow rate.

Author:
Patrice Espie Licensing: LGPL

Field Summary
private  long[] byteSent
           
private  long byteSentCumul
           
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 previousTotalByteSent
           
private  boolean running
           
private  boolean showTrace
           
private  java.lang.String streamName
           
private  long totalByteSent
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
FlowRateOutputStream(java.io.OutputStream out)
           
FlowRateOutputStream(java.io.OutputStream out, java.lang.String streamName)
           
FlowRateOutputStream(java.io.OutputStream out, java.lang.String streamName, int measureDuration, int measureInterval)
           
 
Method Summary
 void close()
           
 int currentRate()
           
 java.lang.String currentRateString()
           
 int overallRate()
           
 java.lang.String overallRateString()
           
 void run()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
flush
 
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

byteSent

private long[] byteSent

byteSentCumul

private long byteSentCumul

totalByteSent

private long totalByteSent

previousTotalByteSent

private long previousTotalByteSent

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

FlowRateOutputStream

public FlowRateOutputStream(java.io.OutputStream out,
                            java.lang.String streamName)

FlowRateOutputStream

public FlowRateOutputStream(java.io.OutputStream out,
                            java.lang.String streamName,
                            int measureDuration,
                            int measureInterval)

FlowRateOutputStream

public FlowRateOutputStream(java.io.OutputStream out)
Method Detail

close

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

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

write

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

write

public void write(int b)
           throws java.io.IOException
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException

currentRate

public int currentRate()
                throws java.io.IOException
Throws:
java.io.IOException

overallRate

public int overallRate()
                throws java.io.IOException
Throws:
java.io.IOException

overallRateString

public java.lang.String overallRateString()
                                   throws java.io.IOException
Throws:
java.io.IOException

currentRateString

public java.lang.String currentRateString()

run

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