com.tffenterprises.io
Class AccountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.tffenterprises.io.AccountingInputStream
All Implemented Interfaces:
AccountingInput, java.io.Closeable

public class AccountingInputStream
extends java.io.FilterInputStream
implements AccountingInput

AccountingInputStream is a FilterIntputStream that implements the AccountingInput interface.

Version:
1.0d1 $Date: 2002/10/12 19:59:22 $
Author:
Guillaume Lessard

Field Summary
private  long consumed
          Our register of written bytes.
private  long mark
          Where the stream was last marked.
private  int readLimit
          The read limit set by the mark() method.
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
AccountingInputStream(java.io.InputStream in)
          Constructor, the standard for a FilterInputStream subclass...
 
Method Summary
 long consumed()
          Returns the number of bytes that have been written to the stream or file since the AccountingOutput instance was constructed.
 void mark(int readLimit)
          Mark the underlying stream for a later reset.
 int read()
          Reads a single byte from this input stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes from the stream, copying them starting at offset off to this byte array..
 void reset()
          Reset the underlying stream to the previously marked position.
 long skip(long n)
          Skip over and discard n bytes from the input stream.
 
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

consumed

private long consumed
Our register of written bytes.


mark

private long mark
Where the stream was last marked.


readLimit

private int readLimit
The read limit set by the mark() method.

Constructor Detail

AccountingInputStream

public AccountingInputStream(java.io.InputStream in)
Constructor, the standard for a FilterInputStream subclass...

Parameters:
in - the InputStream to encapsulate
Method Detail

consumed

public long consumed()
Returns the number of bytes that have been written to the stream or file since the AccountingOutput instance was constructed.

Specified by:
consumed in interface AccountingInput
Returns:
the number of bytes that have been written out.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes from the stream, copying them starting at offset off to this byte array..

Overrides:
read in class java.io.FilterInputStream
Parameters:
b - the byte array to which to copy bytes from the stream.
off - the offset at which to start writing bytes to b.
len - the number of bytes to read from the stream
Returns:
the number of bytes that were read.
Throws:
java.io.IOException - if the underlying stream throws such an exception.

read

public int read()
         throws java.io.IOException
Reads a single byte from this input stream.

Overrides:
read in class java.io.FilterInputStream
Returns:
the byte that was read from the input stream.
Throws:
java.io.IOException - if the underlying steram throws such an exception.

skip

public long skip(long n)
          throws java.io.IOException
Skip over and discard n bytes from the input stream.

Overrides:
skip in class java.io.FilterInputStream
Parameters:
n - the number of bytes to skip.
Returns:
the number of bytes that were skipped.
Throws:
java.io.IOException - if the underlying steram throws such an exception.

mark

public void mark(int readLimit)
Mark the underlying stream for a later reset.

Overrides:
mark in class java.io.FilterInputStream
Parameters:
readLimit - the maximum of bytes to remember.

reset

public void reset()
           throws java.io.IOException
Reset the underlying stream to the previously marked position.

Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException - if the underlying steram throws such an exception.