abstract class AbstractByteHasher extends AbstractHasher
Hasher
that handles converting primitives to bytes using a scratch ByteBuffer
and streams all bytes to a sink to compute the hash.Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
scratch |
Constructor and Description |
---|
AbstractByteHasher() |
Modifier and Type | Method and Description |
---|---|
Hasher |
putByte(byte b)
Puts a byte into this sink.
|
Hasher |
putBytes(byte[] bytes)
Puts an array of bytes into this sink.
|
Hasher |
putBytes(byte[] bytes,
int off,
int len)
Puts a chunk of an array of bytes into this sink.
|
Hasher |
putChar(char c)
Puts a character into this sink.
|
Hasher |
putInt(int i)
Puts an int into this sink.
|
Hasher |
putLong(long l)
Puts a long into this sink.
|
<T> Hasher |
putObject(T instance,
Funnel<? super T> funnel)
A simple convenience for
funnel.funnel(object, this) . |
Hasher |
putShort(short s)
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. |
private Hasher |
update(int bytes)
Updates the sink with the given number of bytes from the buffer.
|
putBoolean, putDouble, putFloat, putString, putUnencodedChars
protected abstract void update(byte b)
protected void update(byte[] b)
protected void update(byte[] b, int off, int len)
len
bytes starting at off
in the given buffer.public Hasher putByte(byte b)
PrimitiveSink
b
- a bytepublic Hasher putBytes(byte[] bytes)
PrimitiveSink
bytes
- a byte arraypublic Hasher putBytes(byte[] bytes, int off, int len)
PrimitiveSink
bytes[off]
is the first byte written,
bytes[off + len - 1]
is the last.bytes
- a byte arrayoff
- the start offset in the arraylen
- the number of bytes to writeprivate Hasher update(int bytes)
public Hasher putShort(short s)
PrimitiveSink
public Hasher putInt(int i)
PrimitiveSink
public Hasher putLong(long l)
PrimitiveSink
public Hasher putChar(char c)
PrimitiveSink