Top Description Inners Fields Constructors Methods
com.google.common.hash

pack-priv final Class MessageDigestHashFunction

extends AbstractHashFunction
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@Immutable
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkNotNull, .Preconditions.checkState

HashFunction adapter for MessageDigest instances.
Authors
Kevin Bourrillion, Dimitris Andreou

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MessageDigestHashFunction.MessageDigestHasher

Hasher that updates a message digest.

private static class

Field Summary

Modifier and TypeField and Description
private final int
private final MessageDigest
private final boolean
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
MessageDigestHashFunction(String algorithmName, String toString)

pack-priv
MessageDigestHashFunction(String algorithmName, int bytes, String toString)

Method Summary

Modifier and TypeMethod and Description
public int
bits()

Implements com.google.common.hash.HashFunction.bits.

Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.
private static MessageDigest
getMessageDigest(String algorithmName)

public Hasher
newHasher()

Implements com.google.common.hash.HashFunction.newHasher.

Begins a new hash code computation by returning an initialized, stateful Hasher instance that is ready to receive data.
private void
private static boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
pack-priv Object
Inherited from com.google.common.hash.AbstractHashFunction:
hashByteshashByteshashByteshashInthashLonghashObjecthashStringhashUnencodedCharsnewHasher

Field Detail

bytesback to summary
private final int bytes
prototypeback to summary
private final MessageDigest prototype
Annotations
@SuppressWarnings:Immutable
supportsCloneback to summary
private final boolean supportsClone
toStringback to summary
private final String toString

Constructor Detail

MessageDigestHashFunctionback to summary
pack-priv MessageDigestHashFunction(String algorithmName, String toString)
MessageDigestHashFunctionback to summary
pack-priv MessageDigestHashFunction(String algorithmName, int bytes, String toString)

Method Detail

bitsback to summary
public int bits()

Implements com.google.common.hash.HashFunction.bits.

Doc from com.google.common.hash.HashFunction.bits.

Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.

Annotations
@Override
getMessageDigestback to summary
private static MessageDigest getMessageDigest(String algorithmName)
newHasherback to summary
public Hasher newHasher()

Implements com.google.common.hash.HashFunction.newHasher.

Doc from com.google.common.hash.HashFunction.newHasher.

Begins a new hash code computation by returning an initialized, stateful Hasher instance that is ready to receive data. Example:

HashFunction hf = Hashing.md5();
HashCode hc = hf.newHasher()
    .putLong(id)
    .putBoolean(isActive)
    .hash();
Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream stream) throws InvalidObjectException
supportsCloneback to summary
private static boolean supportsClone(MessageDigest digest)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()
com.google.common.hash back to summary

private final Class MessageDigestHashFunction.MessageDigestHasher

extends AbstractByteHasher
Class Inheritance

Hasher that updates a message digest.

Field Summary

Modifier and TypeField and Description
private final int
private final MessageDigest
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
public HashCode
hash()

Implements com.google.common.hash.Hasher.hash.

Computes a hash code based on the data that have been provided to this hasher.
protected void
update(byte b)

Implements abstract com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with the given byte.
protected void
update(byte[] b, int off, int len)

Overrides com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with len bytes starting at off in the given buffer.
protected void
update(ByteBuffer bytes)

Overrides com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with bytes from the given buffer.
Inherited from com.google.common.hash.AbstractByteHasher:
putByteputBytesputBytesputBytesputCharputIntputLongputShortupdate

Field Detail

bytesback to summary
private final int bytes
digestback to summary
private final MessageDigest digest
doneback to summary
private boolean done

Constructor Detail

MessageDigestHasherback to summary
private MessageDigestHasher(MessageDigest digest, int bytes)

Method Detail

checkNotDoneback to summary
private void checkNotDone()
hashback to summary
public HashCode hash()

Implements com.google.common.hash.Hasher.hash.

Doc from com.google.common.hash.Hasher.hash.

Computes a hash code based on the data that have been provided to this hasher. The result is unspecified if this method is called more than once on the same instance.

Annotations
@Override
updateback to summary
protected void update(byte b)

Implements abstract com.google.common.hash.AbstractByteHasher.update.

Doc from com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with the given byte.

Annotations
@Override
updateback to summary
protected void update(byte[] b, int off, int len)

Overrides com.google.common.hash.AbstractByteHasher.update.

Doc from com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with len bytes starting at off in the given buffer.

Annotations
@Override
updateback to summary
protected void update(ByteBuffer bytes)

Overrides com.google.common.hash.AbstractByteHasher.update.

Doc from com.google.common.hash.AbstractByteHasher.update.

Updates this hasher with bytes from the given buffer.

Annotations
@Override
com.google.common.hash back to summary

private final Class MessageDigestHashFunction.SerializedForm

extends Object
implements Serializable
Class Inheritance
  • java.lang.Object
  • com.google.common.hash.MessageDigestHashFunction.SerializedForm
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private final int
private static final long
private final String

Constructor Summary

AccessConstructor and Description
private
SerializedForm(String algorithmName, int bytes, String toString)

Method Summary

Modifier and TypeMethod and Description
private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmNameback to summary
private final String algorithmName
bytesback to summary
private final int bytes
serialVersionUIDback to summary
private static final long serialVersionUID
toStringback to summary
private final String toString

Constructor Detail

SerializedFormback to summary
private SerializedForm(String algorithmName, int bytes, String toString)

Method Detail

readResolveback to summary
private Object readResolve()