Class IntStatefulLongHash

java.lang.Object
com.scurrilous.circe.impl.IntStatefulLongHash
All Implemented Interfaces:
Hash, StatefulHash, StatefulLongHash

public final class IntStatefulLongHash extends Object implements StatefulLongHash
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new IntStatefulLongHash that delegates to the given StatefulIntHash.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the canonical name of this hash algorithm.
    Returns an instance of stateless version of this hash function.
    Returns a new instance of this stateful hash function reset to the initial state.
    byte
    Returns the first byte of the output of this hash function.
    byte[]
    Returns a new byte array containing the output of this hash function.
    int
    getBytes(byte[] output, int index, int maxLength)
    Writes the output of this hash function into the given byte array at the given offset.
    int
    Returns the first four bytes of the output of this hash function as a little-endian int.
    long
    Returns the first eight bytes of the output of this hash function as a little-endian long.
    short
    Returns the first two bytes of the output of this hash function as a little-endian short.
    int
    Returns the length in bytes of the output of this hash function.
    void
    Resets this hash function to its initial state.
    boolean
    Returns whether this hash function supports incremental hashing.
    boolean
    Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such as StatefulHash.update(long, long), StatelessIntHash.calculate(long, long), or IncrementalIntHash.resume(int, long, long).
    void
    update(byte[] input)
    Updates the state of this hash function with the entire given input array.
    void
    update(byte[] input, int index, int length)
    Updates the state of this hash function with the given range of the given input array.
    void
    update(long address, long length)
    Updates the state of this hash function with memory with the given address and length.
    void
    Updates the state of this hash function with the remaining contents of the given input buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • asStateless

      public StatelessLongHash asStateless()
      Description copied from interface: StatefulLongHash
      Returns an instance of stateless version of this hash function.
      Specified by:
      asStateless in interface StatefulLongHash
      Returns:
      the stateless version of this hash function
    • algorithm

      public String algorithm()
      Description copied from interface: Hash
      Returns the canonical name of this hash algorithm.
      Specified by:
      algorithm in interface Hash
      Returns:
      the name of this hash algorithm
    • length

      public int length()
      Description copied from interface: Hash
      Returns the length in bytes of the output of this hash function.
      Specified by:
      length in interface Hash
      Returns:
      the hash length in bytes
    • createNew

      public StatefulHash createNew()
      Description copied from interface: StatefulHash
      Returns a new instance of this stateful hash function reset to the initial state.
      Specified by:
      createNew in interface StatefulHash
      Returns:
      a new instance of this hash in the initial state
    • supportsUnsafe

      public boolean supportsUnsafe()
      Description copied from interface: Hash
      Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such as StatefulHash.update(long, long), StatelessIntHash.calculate(long, long), or IncrementalIntHash.resume(int, long, long). Such functions are generally implemented in native code.
      Specified by:
      supportsUnsafe in interface Hash
      Returns:
      true if unsafe access is supported, false if not
    • supportsIncremental

      public boolean supportsIncremental()
      Description copied from interface: StatefulHash
      Returns whether this hash function supports incremental hashing. Incremental hashing allows calling the StatefulHash.update(byte[]) methods to continue hashing using accumulated state after calling any of the output methods (such as StatefulHash.getBytes()). Non-incremental hash functions require calling StatefulHash.reset() to reinitialize the state between calling an output method and an update method.
      Specified by:
      supportsIncremental in interface StatefulHash
      Returns:
      true if incremental hashing is supported, false if not
    • reset

      public void reset()
      Description copied from interface: StatefulHash
      Resets this hash function to its initial state. Resetting the state is required for non-incremental hash functions after any output methods have been called.
      Specified by:
      reset in interface StatefulHash
    • update

      public void update(byte[] input)
      Description copied from interface: StatefulHash
      Updates the state of this hash function with the entire given input array.
      Specified by:
      update in interface StatefulHash
      Parameters:
      input - the input array
    • update

      public void update(byte[] input, int index, int length)
      Description copied from interface: StatefulHash
      Updates the state of this hash function with the given range of the given input array.
      Specified by:
      update in interface StatefulHash
      Parameters:
      input - the input array
      index - the starting index of the first input byte
      length - the length of the input range
    • update

      public void update(ByteBuffer input)
      Description copied from interface: StatefulHash
      Updates the state of this hash function with the remaining contents of the given input buffer. This method leaves the buffer position at the limit.
      Specified by:
      update in interface StatefulHash
      Parameters:
      input - the input buffer
    • update

      public void update(long address, long length)
      Description copied from interface: StatefulHash
      Updates the state of this hash function with memory with the given address and length. The arguments are generally not checked in any way and will likely lead to a VM crash or undefined results if invalid.
      Specified by:
      update in interface StatefulHash
      Parameters:
      address - the base address of the input
      length - the length of the input
      See Also:
    • getBytes

      public byte[] getBytes()
      Description copied from interface: StatefulHash
      Returns a new byte array containing the output of this hash function. The caller may freely modify the contents of the array.
      Specified by:
      getBytes in interface StatefulHash
      Returns:
      a new byte array containing the hash output
    • getBytes

      public int getBytes(byte[] output, int index, int maxLength)
      Description copied from interface: StatefulHash
      Writes the output of this hash function into the given byte array at the given offset.
      Specified by:
      getBytes in interface StatefulHash
      Parameters:
      output - the destination array for the output
      index - the starting index of the first output byte
      maxLength - the maximum number of bytes to write
      Returns:
      the number of bytes written
    • getByte

      public byte getByte()
      Description copied from interface: StatefulHash
      Returns the first byte of the output of this hash function.
      Specified by:
      getByte in interface StatefulHash
      Returns:
      the first output byte
    • getShort

      public short getShort()
      Description copied from interface: StatefulHash
      Returns the first two bytes of the output of this hash function as a little-endian short. If the output is less than two bytes, the remaining bytes are set to 0.
      Specified by:
      getShort in interface StatefulHash
      Returns:
      the first two output bytes as a short
    • getInt

      public int getInt()
      Description copied from interface: StatefulHash
      Returns the first four bytes of the output of this hash function as a little-endian int. If the output is less than four bytes, the remaining bytes are set to 0.
      Specified by:
      getInt in interface StatefulHash
      Returns:
      the first four output bytes as an int
    • getLong

      public long getLong()
      Description copied from interface: StatefulHash
      Returns the first eight bytes of the output of this hash function as a little-endian long. If the output is less than eight bytes, the remaining bytes are set to 0.
      Specified by:
      getLong in interface StatefulHash
      Returns:
      the first eight output bytes as a long