|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--java.io.FilterInputStream | +--gausssoft.io.StatusInputStream | +--gausssoft.io.ChunkingInputStream | +--gausssoft.io.BandwidthInputStream
This class measures the level of throughput that goes into an underlying InputStream
.
This implementation uses the ChunkingInputStream
class to perform updates.
It is recommended that you look at how the ChunkingInputStream
class
works before using this class.
The bandwidth is calculated every time an interrupt is performed. It is necessary to
call the initiate()
method to begin measuring throughput. You can also
call the resetMeasuring()
to discard previous bandwidth calculations.
Bandwidth is calculated by taking the number of bytes passed since initiate
or
resetMeasuring
was last called. Bandwidth is calculated in bytes per second.
When the stream is empty, the bandwidth at that point is calculated, and is subsequently
returned every time getBandwidth()
is invoked.
BandwidthOutputStream
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary | |
|
BandwidthInputStream(InputStream in)
Creates a BandwidthInputStream that does not use cumulative totals, chunks data into 1024 bytes, and performs start-of-call and end-of-call interrupts. |
|
BandwidthInputStream(InputStream in,
int chunksize)
Creates a BandwidthInputStream that does not use cumulative totals, and performs start-of-call and end-of-call interrupts. |
protected |
BandwidthInputStream(InputStream in,
int chunksize,
boolean cumulative,
boolean start)
Creates a BandwidthInputStream that performs end-of-call interrupts. |
Method Summary | |
void |
close()
|
int |
getBandwidth()
Calculates the bandwidth in bytes per second. |
void |
initiate()
Begins measuring bandwidth. |
boolean |
initiated()
Indicates if this stream has been initiated yet. |
protected void |
interrupt()
Used for bandwidth calculations. |
void |
resetMeasuring()
Discards all previous calculation data. |
Methods inherited from class gausssoft.io.ChunkingInputStream |
getChunkSize, read, read, read, setChunkSize, skip, updateChunkSize |
Methods inherited from class gausssoft.io.StatusInputStream |
available, getCount, isClosed, isEmpty |
Methods inherited from class java.io.FilterInputStream |
mark, markSupported, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BandwidthInputStream(InputStream in)
The initiate()
method must be called to begin measuring.
in
- The InputStream to wrap around.NullPointerException
- If in
is null
.public BandwidthInputStream(InputStream in, int chunksize)
The initiate()
method must be called to begin measuring.
in
- The InputStream to wrap around.chunksize
- The chunk size to use.NullPointerException
- If in
is null
.IllegalArgumentException
- If chunksize
is less than 1.protected BandwidthInputStream(InputStream in, int chunksize, boolean cumulative, boolean start)
The initiate()
method must be called to begin measuring.
in
- The InputStream to wrap around.chunksize
- The chunk size to use.cumulative
- true
if this object should use the getCount
method
for calculations, false
to use an internal counter.start
- true
if this object should perform start-of-call interrupts.NullPointerException
- If in
is null
.IllegalArgumentException
- If chunksize
is less than 1.Method Detail |
public void initiate()
resetMeasuring()
,
initiated()
protected void interrupt()
interrupt
in class ChunkingInputStream
ChunkingOutputStream.interrupt()
public final boolean initiated()
true
if this stream has been initiated.initiate()
public final void resetMeasuring()
public final int getBandwidth()
IllegalStateException
- If this method is invoked before the object is initialised.public void close() throws IOException
close
in class StatusInputStream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |