Package com.google.common.hash
Class AbstractByteHasher
- java.lang.Object
-
- com.google.common.hash.AbstractHasher
-
- com.google.common.hash.AbstractByteHasher
-
- All Implemented Interfaces:
Hasher,PrimitiveSink
- Direct Known Subclasses:
ChecksumHashFunction.ChecksumHasher,Crc32cHashFunction.Crc32cHasher,MacHashFunction.MacHasher,MessageDigestHashFunction.MessageDigestHasher
abstract class AbstractByteHasher extends AbstractHasher
AbstractHasherthat handles converting primitives to bytes using a scratchByteBufferand streams all bytes to a sink to compute the hash.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferscratch
-
Constructor Summary
Constructors Constructor Description AbstractByteHasher()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description HasherputByte(byte b)Puts a byte into this sink.HasherputBytes(byte[] bytes)Puts an array of bytes into this sink.HasherputBytes(byte[] bytes, int off, int len)Puts a chunk of an array of bytes into this sink.HasherputChar(char c)Puts a character into this sink.HasherputInt(int i)Puts an int into this sink.HasherputLong(long l)Puts a long into this sink.<T> HasherputObject(T instance, Funnel<? super T> funnel)A simple convenience forfunnel.funnel(object, this).HasherputShort(short s)Puts a short into this sink.protected abstract voidupdate(byte b)Updates this hasher with the given byte.protected voidupdate(byte[] b)Updates this hasher with the given bytes.protected voidupdate(byte[] b, int off, int len)Updates this hasher withlenbytes starting atoffin the given buffer.private Hasherupdate(int bytes)Updates the sink with the given number of bytes from the buffer.-
Methods inherited from class com.google.common.hash.AbstractHasher
putBoolean, putDouble, putFloat, putString, putUnencodedChars
-
-
-
-
Method Detail
-
update
protected abstract void update(byte b)
Updates this hasher with the given byte.
-
update
protected void update(byte[] b)
Updates this hasher with the given bytes.
-
update
protected void update(byte[] b, int off, int len)Updates this hasher withlenbytes starting atoffin the given buffer.
-
putByte
public Hasher putByte(byte b)
Description copied from interface:PrimitiveSinkPuts a byte into this sink.- Parameters:
b- a byte- Returns:
- this instance
-
putBytes
public Hasher putBytes(byte[] bytes)
Description copied from interface:PrimitiveSinkPuts an array of bytes into this sink.- Parameters:
bytes- a byte array- Returns:
- this instance
-
putBytes
public Hasher putBytes(byte[] bytes, int off, int len)
Description copied from interface:PrimitiveSinkPuts 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- a byte arrayoff- the start offset in the arraylen- the number of bytes to write- Returns:
- this instance
-
update
private Hasher update(int bytes)
Updates the sink with the given number of bytes from the buffer.
-
putShort
public Hasher putShort(short s)
Description copied from interface:PrimitiveSinkPuts a short into this sink.
-
putInt
public Hasher putInt(int i)
Description copied from interface:PrimitiveSinkPuts an int into this sink.
-
putLong
public Hasher putLong(long l)
Description copied from interface:PrimitiveSinkPuts a long into this sink.
-
putChar
public Hasher putChar(char c)
Description copied from interface:PrimitiveSinkPuts a character into this sink.
-
-