| Modifier and Type | Method and Description |
|---|---|
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 8.
|
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. |
abstract long |
padToLong()
If this hashcode has enough bits, returns
asLong(), otherwise returns a long
value with asInt() as the least-significant four bytes and 0x00 as
each of the most-significant four bytes. |
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. |
public abstract int asInt()
int value in little-endian order.IllegalStateException - if bits() < 32public abstract long asLong()
long value in little-endian order.IllegalStateException - if bits() < 64public abstract long padToLong()
asLong(), otherwise returns a long
value with asInt() as the least-significant four bytes and 0x00 as
each of the most-significant four bytes.Hashing.padToLong(HashCode))public abstract byte[] asBytes()
HashCode object or any other arrays
returned by this method.public int writeBytesTo(byte[] dest, int offset, int maxLength)
dest.dest - the byte array into which the hash code will be writtenoffset - the start offset in the datamaxLength - the maximum number of bytes to writedestIndexOutOfBoundsException - if there is not enough room in destpublic abstract int bits()
public int hashCode()
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.public String toString()
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.
Copyright © 2010-2013. All Rights Reserved.