Package com.google.common.hash
Class AbstractNonStreamingHashFunction.BufferingHasher
- java.lang.Object
-
- com.google.common.hash.AbstractHasher
-
- com.google.common.hash.AbstractNonStreamingHashFunction.BufferingHasher
-
- All Implemented Interfaces:
Hasher
,PrimitiveSink
- Enclosing class:
- AbstractNonStreamingHashFunction
private final class AbstractNonStreamingHashFunction.BufferingHasher extends AbstractHasher
In-memory stream-based implementation of Hasher.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) AbstractNonStreamingHashFunction.ExposedByteArrayOutputStream
stream
-
Constructor Summary
Constructors Constructor Description BufferingHasher(int expectedInputSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashCode
hash()
Computes a hash code based on the data that have been provided to this hasher.Hasher
putByte(byte b)
Puts a byte 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.-
Methods inherited from class com.google.common.hash.AbstractHasher
putBoolean, putBytes, putChar, putDouble, putFloat, putInt, putLong, putObject, putShort, putString, putUnencodedChars
-
-
-
-
Field Detail
-
stream
final AbstractNonStreamingHashFunction.ExposedByteArrayOutputStream stream
-
-
Method Detail
-
putByte
public Hasher putByte(byte b)
Description copied from interface:PrimitiveSink
Puts a byte into this sink.- Parameters:
b
- a byte- Returns:
- this instance
-
putBytes
public Hasher putBytes(byte[] bytes, int off, int len)
Description copied from interface:PrimitiveSink
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.- Specified by:
putBytes
in interfaceHasher
- Specified by:
putBytes
in interfacePrimitiveSink
- Overrides:
putBytes
in classAbstractHasher
- Parameters:
bytes
- a byte arrayoff
- the start offset in the arraylen
- the number of bytes to write- Returns:
- this instance
-
putBytes
public Hasher putBytes(java.nio.ByteBuffer bytes)
Description copied from interface:PrimitiveSink
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.- Specified by:
putBytes
in interfaceHasher
- Specified by:
putBytes
in interfacePrimitiveSink
- Overrides:
putBytes
in classAbstractHasher
- Parameters:
bytes
- a byte buffer- Returns:
- this instance
-
-