org.modeshape.common.util

## Class SecureHash.HashingInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.modeshape.common.util.SecureHash.HashingInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Enclosing class:
    SecureHash

      public static class SecureHash.HashingInputStream
      extends InputStream

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SecureHash.HashingInputStream(MessageDigest digest, InputStream input)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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`

    - #### read

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

      Overrides:
        `read` in class `InputStream`
      Throws:
        `IOException`

    - #### read

          public int read(byte[] b)
                   throws IOException

      Overrides:
        `read` in class `InputStream`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `InputStream`
      Throws:
        `IOException`

    - #### 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-2014 JBoss, a division of Red Hat. All Rights Reserved.