org.entityfs.support.io
Class ChecksumInputStream<T extends Checksum>

java.lang.Object
  extended by java.io.InputStream
      extended by org.entityfs.support.io.InputStreamProxy
          extended by org.entityfs.support.io.ChecksumInputStream<T>
All Implemented Interfaces:
Closeable

public class ChecksumInputStream<T extends Checksum>
extends InputStreamProxy

This InputStream calculates the checksum of the data it reads from a wrapped stream.

Since:
1.1
Author:
Karl Gustafsson
In_jar:
entityfs-core

Constructor Summary
ChecksumInputStream(InputStream wrapped, T checksum)
          Create a new checksum input stream.
 
Method Summary
 T getChecksum()
          Get the checksum.
 void mark(int readlimit)
          This method does nothing.
 boolean markSupported()
           
 int read()
           
 int read(byte[] barr)
           
 int read(byte[] barr, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class org.entityfs.support.io.InputStreamProxy
available, close, getProxied, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChecksumInputStream

public ChecksumInputStream(InputStream wrapped,
                           T checksum)
Create a new checksum input stream.

Parameters:
wrapped - The stream to read data from.
checksum - The checksum object to use for calculating the checksum.
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class InputStreamProxy
Throws:
IOException

read

public int read(byte[] barr)
         throws IOException
Overrides:
read in class InputStreamProxy
Throws:
IOException

read

public int read(byte[] barr,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStreamProxy
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStreamProxy
Throws:
IOException

mark

public void mark(int readlimit)
This method does nothing.

Overrides:
mark in class InputStreamProxy

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStreamProxy
Throws:
IOException - Always.

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStreamProxy
Returns:
false, always.

getChecksum

public T getChecksum()
Get the checksum.

Returns:
The checksum.