org.modeshape.common.util
Class SecureHash.HashingReader

java.lang.Object
  extended by java.io.Reader
      extended by org.modeshape.common.util.SecureHash.HashingReader
All Implemented Interfaces:
Closeable, Readable
Enclosing class:
SecureHash

public static class SecureHash.HashingReader
extends Reader


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

Constructor Detail

SecureHash.HashingReader

protected SecureHash.HashingReader(MessageDigest digest,
                                   Reader input,
                                   Charset charset)
Method Detail

read

public int read()
         throws IOException

Overrides:
read in class Reader
Throws:
IOException
See Also:
Reader.read()

read

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

Specified by:
read in class Reader
Throws:
IOException
See Also:
Reader.read(char[], int, int)

read

public int read(char[] b)
         throws IOException

Overrides:
read in class Reader
Throws:
IOException
See Also:
Reader.read(char[])

close

public void close()
           throws IOException

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

getHash

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

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

getHashAsHexString

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

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


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