org.modeshape.common.util
Class SecureHash.HashingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.modeshape.common.util.SecureHash.HashingInputStream
All Implemented Interfaces:
Closeable
Enclosing class:
SecureHash

public static class SecureHash.HashingInputStream
extends InputStream


Constructor Summary
protected SecureHash.HashingInputStream(MessageDigest digest, InputStream input)
           
 
Method Summary
 void close()
          
 byte[] getHash()
          Get the hash of the content read by this stream.
 String getHashAsHexString()
          Get the string representation of the binary hash of the content read by this stream.
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureHash.HashingInputStream

protected SecureHash.HashingInputStream(MessageDigest digest,
                                        InputStream input)
Method Detail

read

public int read()
         throws IOException

Specified by:
read in class InputStream
Throws:
IOException
See Also:
InputStream.read()

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Overrides:
read in class InputStream
Throws:
IOException
See Also:
InputStream.read(byte[], int, int)

read

public int read(byte[] b)
         throws IOException

Overrides:
read in class InputStream
Throws:
IOException
See Also:
InputStream.read(byte[])

close

public void close()
           throws IOException

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException
See Also:
InputStream.close()

getHash

public byte[] getHash()
Get the hash of the content read by this stream. This method will return null if the stream has not yet been closed.

Returns:
the hash of the contents as a byte array, or null if the stream has not yet been closed

getHashAsHexString

public String getHashAsHexString()
Get the string representation of the binary hash of the content read by this stream. This method will return null if the stream has not yet been closed.

Returns:
the hex-encoded representation of the binary hash of the contents, or null if the stream has not yet been closed


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.