org.jaudiotagger.audio.asf.io
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.jaudiotagger.audio.asf.io.CountingInputStream
All Implemented Interfaces:
java.io.Closeable

 class CountingInputStream
extends java.io.FilterInputStream

This implementation of FilterInputStream counts each read byte.
So at each time, with getReadCount() one can determine how many bytes have been read, by this classes read and skip methods (mark and reset are also taken into account).

Author:
Christian Laireiter

Field Summary
private  long markPos
          If mark(int) has been called, the current value of readCount is stored, in order to reset it upon reset().
private  long readCount
          The amount of read or skipped bytes.
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CountingInputStream(java.io.InputStream stream)
          Creates an instance, which delegates the commands to the given stream.
 
Method Summary
private  void bytesRead(long amountRead)
          Counts the given amount of bytes.
 long getReadCount()
           
 void mark(int readlimit)
          
 int read()
          
 int read(byte[] destination, int off, int len)
          
 void reset()
          
 long skip(long amount)
          
 
Methods inherited from class java.io.FilterInputStream
available, close, markSupported, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

markPos

private long markPos
If mark(int) has been called, the current value of readCount is stored, in order to reset it upon reset().


readCount

private long readCount
The amount of read or skipped bytes.

Constructor Detail

CountingInputStream

public CountingInputStream(java.io.InputStream stream)
Creates an instance, which delegates the commands to the given stream.

Parameters:
stream - stream to actually work with.
Method Detail

bytesRead

private void bytesRead(long amountRead)
Counts the given amount of bytes.

Parameters:
amountRead - number of bytes to increase.

getReadCount

public long getReadCount()
Returns:
the readCount

mark

public void mark(int readlimit)

Overrides:
mark in class java.io.FilterInputStream

read

public int read()
         throws java.io.IOException

Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] destination,
                int off,
                int len)
         throws java.io.IOException

Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException

Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException

skip

public long skip(long amount)
          throws java.io.IOException

Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.IOException