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 |
putBytes(java.nio.ByteBuffer bytes)
Puts the remaining bytes of a byte buffer 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.
|
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. |
protected void |
update(java.nio.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.
|
putBoolean, putDouble, putFloat, putObject, putString, putUnencodedCharsprotected 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.protected void update(java.nio.ByteBuffer b)
private Hasher update(int bytes)
public Hasher putByte(byte b)
PrimitiveSinkb - a bytepublic Hasher putBytes(byte[] bytes)
PrimitiveSinkputBytes in interface HasherputBytes in interface PrimitiveSinkputBytes in class AbstractHasherbytes - a byte arraypublic Hasher putBytes(byte[] bytes, int off, int len)
PrimitiveSinkbytes[off] is the first byte written,
bytes[off + len - 1] is the last.putBytes in interface HasherputBytes in interface PrimitiveSinkputBytes in class AbstractHasherbytes - a byte arrayoff - the start offset in the arraylen - the number of bytes to writepublic Hasher putBytes(java.nio.ByteBuffer bytes)
PrimitiveSinkbytes.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.putBytes in interface HasherputBytes in interface PrimitiveSinkputBytes in class AbstractHasherbytes - a byte bufferpublic Hasher putShort(short s)
PrimitiveSinkputShort in interface HasherputShort in interface PrimitiveSinkputShort in class AbstractHasherpublic Hasher putInt(int i)
PrimitiveSinkputInt in interface HasherputInt in interface PrimitiveSinkputInt in class AbstractHasherpublic Hasher putLong(long l)
PrimitiveSinkputLong in interface HasherputLong in interface PrimitiveSinkputLong in class AbstractHasherpublic Hasher putChar(char c)
PrimitiveSinkputChar in interface HasherputChar in interface PrimitiveSinkputChar in class AbstractHasher