Package com.google.common.hash
Class AbstractHasher
- java.lang.Object
-
- com.google.common.hash.AbstractHasher
-
- All Implemented Interfaces:
Hasher,PrimitiveSink
- Direct Known Subclasses:
AbstractByteHasher,AbstractNonStreamingHashFunction.BufferingHasher,AbstractStreamingHashFunction.AbstractStreamingHasher
abstract class AbstractHasher extends java.lang.Object implements Hasher
An abstract hasher, implementingputBoolean(boolean),putDouble(double),putFloat(float),putUnencodedChars(CharSequence), andputString(CharSequence, Charset)as prescribed byHasher.
-
-
Constructor Summary
Constructors Constructor Description AbstractHasher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HasherputBoolean(boolean b)Equivalent toputByte(b ? (byte) 1 : (byte) 0).HasherputDouble(double d)Equivalent toputLong(Double.doubleToRawLongBits(d)).HasherputFloat(float f)Equivalent toputInt(Float.floatToRawIntBits(f)).HasherputString(java.lang.CharSequence charSequence, java.nio.charset.Charset charset)Equivalent toputBytes(charSequence.toString().getBytes(charset)).HasherputUnencodedChars(java.lang.CharSequence charSequence)Equivalent to processing eachcharvalue in theCharSequence, in order.
-
-
-
Method Detail
-
putBoolean
public final Hasher putBoolean(boolean b)
Description copied from interface:HasherEquivalent toputByte(b ? (byte) 1 : (byte) 0).- Specified by:
putBooleanin interfaceHasher- Specified by:
putBooleanin interfacePrimitiveSink
-
putDouble
public final Hasher putDouble(double d)
Description copied from interface:HasherEquivalent toputLong(Double.doubleToRawLongBits(d)).- Specified by:
putDoublein interfaceHasher- Specified by:
putDoublein interfacePrimitiveSink
-
putFloat
public final Hasher putFloat(float f)
Description copied from interface:HasherEquivalent toputInt(Float.floatToRawIntBits(f)).- Specified by:
putFloatin interfaceHasher- Specified by:
putFloatin interfacePrimitiveSink
-
putUnencodedChars
public Hasher putUnencodedChars(java.lang.CharSequence charSequence)
Description copied from interface:HasherEquivalent to processing eachcharvalue in theCharSequence, in order. In other words, no character encoding is performed; the low byte and high byte of eachcharare hashed directly (in that order). The input must not be updated while this method is in progress.Warning: This method will produce different output than most other languages do when running the same hash function on the equivalent input. For cross-language compatibility, use
Hasher.putString(java.lang.CharSequence, java.nio.charset.Charset), usually with a charset of UTF-8. For other use cases, useputUnencodedChars.- Specified by:
putUnencodedCharsin interfaceHasher- Specified by:
putUnencodedCharsin interfacePrimitiveSink
-
putString
public Hasher putString(java.lang.CharSequence charSequence, java.nio.charset.Charset charset)
Description copied from interface:HasherEquivalent toputBytes(charSequence.toString().getBytes(charset)).Warning: This method, which reencodes the input before hashing it, is useful only for cross-language compatibility. For other use cases, prefer
Hasher.putUnencodedChars(java.lang.CharSequence), which is faster, produces the same output across Java releases, and hashes everycharin the input, even if some are invalid.- Specified by:
putStringin interfaceHasher- Specified by:
putStringin interfacePrimitiveSink
-
-