Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.common.hash
Class HashCode

    java.lang.Object
      com.google.common.hash.HashCode

    @Beta
    public abstract class HashCode

extends Object

An immutable hash code of arbitrary bit length.

Since:
  11.0
Author:
  Dimitris Andreou

Method Summary
`abstract byte[]` | `asBytes()` Returns the value of this hash code as a byte array.
`abstract int` | `asInt()` Returns the first four bytes of this hashcode's bytes, converted to an `int` value in little-endian order.
`abstract long` | `asLong()` Returns the first eight bytes of this hashcode's bytes, converted to a `long` value in little-endian order.
`abstract int` | `bits()` Returns the number of bits in this hash code; a positive multiple of 32.
`boolean` | `equals(Object object)`
`int` | `hashCode()` Returns a "Java hash code" for this `HashCode` instance; this is well-defined (so, for example, you can safely put `HashCode` instances into a `HashSet`) but is otherwise probably not what you want to use.
`String` | `toString()` Returns a string containing each byte of `asBytes()`, in order, as a two-digit unsigned hexadecimal number in lower case.
`int` | `writeBytesTo(byte[] dest, int offset, int maxLength)` Copies bytes from this hash code into `dest`.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### asInt

    public abstract int asInt()

  Returns the first four bytes of this hashcode's bytes, converted to an `int` value in little-endian order.

### asLong

    public abstract long asLong()

  Returns the first eight bytes of this hashcode's bytes, converted to a `long` value in little-endian order.

  Throws:
    `IllegalStateException` - if `bits() < 64`

### asBytes

    public abstract byte[] asBytes()

  Returns the value of this hash code as a byte array. The caller may modify the byte array; changes to it will not be reflected in this `HashCode` object or any other arrays returned by this method.

### writeBytesTo

    public int writeBytesTo(byte[] dest,
                            int offset,
                            int maxLength)

  Copies bytes from this hash code into `dest`.

  Parameters:
    `dest` - the byte array into which the hash code will be written
    `offset` - the start offset in the data
    `maxLength` - the maximum number of bytes to write
  Returns:
    the number of bytes written to `dest`
  Throws:
    `IndexOutOfBoundsException` - if there is not enough room in `dest`

### bits

    public abstract int bits()

  Returns the number of bits in this hash code; a positive multiple of 32.

### equals

    public boolean equals(Object object)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns a "Java hash code" for this `HashCode` instance; this is well-defined (so, for example, you can safely put `HashCode` instances into a `HashSet`) but is otherwise probably not what you want to use.

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Returns a string containing each byte of `asBytes()`, in order, as a two-digit unsigned hexadecimal number in lower case.

  Note that if the output is considered to be a single hexadecimal number, this hash code's bytes are the big-endian representation of that number. This may be surprising since everything else in the hashing API uniformly treats multibyte values as little-endian. But this format conveniently matches that of utilities such as the UNIX `md5sum` command.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010-2012. All Rights Reserved.