Top Description Fields Constructors Methods
com.google.common.hash

pack-priv abstract Class AbstractByteHasher

extends AbstractHasher
Class Inheritance
Known Direct Subclasses
com.google.common.hash.ChecksumHashFunction.ChecksumHasher, com.google.common.hash.MacHashFunction.MacHasher, com.google.common.hash.MessageDigestHashFunction.MessageDigestHasher
Annotations
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, .Preconditions.checkPositionIndexes

Abstract Hasher that handles converting primitives to bytes using a scratch ByteBuffer and streams all bytes to a sink to compute the hash.
Author
Colin Decker

Field Summary

Modifier and TypeField and Description
private final ByteBuffer

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Hasher
putByte(byte
a byte
b
)

Implements com.google.common.hash.Hasher.putByte.

Puts a byte into this sink.
public Hasher
putBytes(byte[]
a byte array
bytes
)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Puts an array of bytes into this sink.
public Hasher
putBytes(byte[]
a byte array
bytes
,
int
the start offset in the array
off
,
int
the number of bytes to write
len
)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Puts a chunk of an array of bytes into this sink.
public Hasher
putBytes(ByteBuffer
a byte buffer
bytes
)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Puts the remaining bytes of a byte buffer into this sink.
public Hasher
putChar(char c)

Overrides com.google.common.hash.AbstractHasher.putChar.

Implements com.google.common.hash.Hasher.putChar.

Puts a character into this sink.
public Hasher
putInt(int i)

Overrides com.google.common.hash.AbstractHasher.putInt.

Implements com.google.common.hash.Hasher.putInt.

Puts an int into this sink.
public Hasher
putLong(long l)

Overrides com.google.common.hash.AbstractHasher.putLong.

Implements com.google.common.hash.Hasher.putLong.

Puts a long into this sink.
public Hasher
putShort(short s)

Overrides com.google.common.hash.AbstractHasher.putShort.

Implements com.google.common.hash.Hasher.putShort.

Puts a short into this sink.
protected abstract void
update(byte b)

Updates this hasher with the given byte.

protected void
update(byte[] b)

Updates this hasher with the given bytes.

protected void
update(byte[] b, int off, int len)

Updates this hasher with len bytes starting at off in the given buffer.

protected void
update(ByteBuffer b)

Updates this hasher with bytes from the given buffer.

private Hasher
update(int bytes)

Updates the sink with the given number of bytes from the buffer.

Inherited from com.google.common.hash.AbstractHasher:
putBooleanputDoubleputFloatputObjectputStringputUnencodedChars

Field Detail

scratchback to summary
private final ByteBuffer scratch

Constructor Detail

AbstractByteHasherback to summary
pack-priv AbstractByteHasher()

Method Detail

putByteback to summary
public Hasher putByte(byte b)

Implements com.google.common.hash.Hasher.putByte.

Doc from com.google.common.hash.PrimitiveSink.putByte.

Puts a byte into this sink.

Parameters
b:byte

a byte

Returns:Hasher

this instance

Annotations
@Override
@CanIgnoreReturnValue
putBytesback to summary
public Hasher putBytes(byte[] bytes)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Doc from com.google.common.hash.PrimitiveSink.putBytes.

Puts an array of bytes into this sink.

Parameters
bytes:byte[]

a byte array

Returns:Hasher

this instance

Annotations
@Override
@CanIgnoreReturnValue
putBytesback to summary
public Hasher putBytes(byte[] bytes, int off, int len)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Doc from com.google.common.hash.PrimitiveSink.putBytes.

Puts a chunk of an array of bytes into this sink. bytes[off] is the first byte written, bytes[off + len - 1] is the last.

Parameters
bytes:byte[]

a byte array

off:int

the start offset in the array

len:int

the number of bytes to write

Returns:Hasher

this instance

Annotations
@Override
@CanIgnoreReturnValue
putBytesback to summary
public Hasher putBytes(ByteBuffer bytes)

Overrides com.google.common.hash.AbstractHasher.putBytes.

Implements com.google.common.hash.Hasher.putBytes.

Doc from com.google.common.hash.PrimitiveSink.putBytes.

Puts the remaining bytes of a byte buffer into this sink. bytes.position() is the first byte written, bytes.limit() - 1 is the last. The position of the buffer will be equal to the limit when this method returns.

Parameters
bytes:ByteBuffer

a byte buffer

Returns:Hasher

this instance

Annotations
@Override
@CanIgnoreReturnValue
putCharback to summary
public Hasher putChar(char c)

Overrides com.google.common.hash.AbstractHasher.putChar.

Implements com.google.common.hash.Hasher.putChar.

Doc from com.google.common.hash.PrimitiveSink.putChar.

Puts a character into this sink.

Annotations
@Override
@CanIgnoreReturnValue
putIntback to summary
public Hasher putInt(int i)

Overrides com.google.common.hash.AbstractHasher.putInt.

Implements com.google.common.hash.Hasher.putInt.

Doc from com.google.common.hash.PrimitiveSink.putInt.

Puts an int into this sink.

Annotations
@Override
@CanIgnoreReturnValue
putLongback to summary
public Hasher putLong(long l)

Overrides com.google.common.hash.AbstractHasher.putLong.

Implements com.google.common.hash.Hasher.putLong.

Doc from com.google.common.hash.PrimitiveSink.putLong.

Puts a long into this sink.

Annotations
@Override
@CanIgnoreReturnValue
putShortback to summary
public Hasher putShort(short s)

Overrides com.google.common.hash.AbstractHasher.putShort.

Implements com.google.common.hash.Hasher.putShort.

Doc from com.google.common.hash.PrimitiveSink.putShort.

Puts a short into this sink.

Annotations
@Override
@CanIgnoreReturnValue
updateback to summary
protected abstract void update(byte b)

Updates this hasher with the given byte.

updateback to summary
protected void update(byte[] b)

Updates this hasher with the given bytes.

updateback to summary
protected void update(byte[] b, int off, int len)

Updates this hasher with len bytes starting at off in the given buffer.

updateback to summary
protected void update(ByteBuffer b)

Updates this hasher with bytes from the given buffer.

updateback to summary
private Hasher update(int bytes)

Updates the sink with the given number of bytes from the buffer.

Annotations
@CanIgnoreReturnValue