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

pack-priv final Class MacHashFunction

extends AbstractHashFunction
Class Inheritance
Annotations
@Immutable
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, .Preconditions.checkState

HashFunction adapter for Mac instances.
Author
Kurt Alfred Kluever

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MacHashFunction.MacHasher

Hasher that updates a Mac (message authentication code).

Field Summary

Modifier and TypeField and Description
private final int
private final Key
private final Mac
private final boolean
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
MacHashFunction(String algorithmName, Key key, 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 Mac
getMac(String algorithmName, Key key)

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 static boolean
public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

bitsback to summary
private final int bits
keyback to summary
private final Key key
Annotations
@SuppressWarnings:Immutable
prototypeback to summary
private final Mac prototype
Annotations
@SuppressWarnings:Immutable
supportsCloneback to summary
private final boolean supportsClone
toStringback to summary
private final String toString

Constructor Detail

MacHashFunctionback to summary
pack-priv MacHashFunction(String algorithmName, Key key, 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
getMacback to summary
private static Mac getMac(String algorithmName, Key key)
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
supportsCloneback to summary
private static boolean supportsClone(Mac mac)
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
com.google.common.hash back to summary

private final Class MacHashFunction.MacHasher

extends AbstractByteHasher
Class Inheritance

Hasher that updates a Mac (message authentication code).

Field Summary

Modifier and TypeField and Description
private boolean
private final Mac

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)

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

Updates this hasher with the given bytes.
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:
putByteputBytesputBytesputBytesputCharputIntputLongputShort

Field Detail

doneback to summary
private boolean done
macback to summary
private final Mac mac

Constructor Detail

MacHasherback to summary
private MacHasher(Mac mac)

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)

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

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

Updates this hasher with the given bytes.

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