Package com.scurrilous.circe.crc
Class JavaCrc32
- java.lang.Object
-
- com.scurrilous.circe.impl.AbstractStatefulHash
-
- com.scurrilous.circe.crc.JavaCrc32
-
- All Implemented Interfaces:
Hash,StatefulHash,StatefulIntHash
final class JavaCrc32 extends AbstractStatefulHash implements StatefulIntHash
WrapsCRC32in aStatefulIntHash.
-
-
Constructor Summary
Constructors Constructor Description JavaCrc32()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringalgorithm()Returns the canonical name of this hash algorithm.StatelessIntHashasStateless()Returns an instance of stateless version of this hash function.StatefulHashcreateNew()Returns a new instance of this stateful hash function reset to the initial state.intgetInt()Returns the first four bytes of the output of this hash function as a little-endianint.longgetLong()Returns the first eight bytes of the output of this hash function as a little-endianlong.intlength()Returns the length in bytes of the output of this hash function.voidreset()Resets this hash function to its initial state.booleansupportsIncremental()Returns whether this hash function supports incremental hashing.protected voidupdateUnchecked(byte[] input, int index, int length)Updates the state of this hash function with the given range of the given input array.-
Methods inherited from class com.scurrilous.circe.impl.AbstractStatefulHash
getByte, getBytes, getBytes, getShort, supportsUnsafe, update, update, update, update, writeBytes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.scurrilous.circe.Hash
supportsUnsafe
-
-
-
-
Method Detail
-
algorithm
public java.lang.String algorithm()
Description copied from interface:HashReturns the canonical name of this hash algorithm.
-
length
public int length()
Description copied from interface:HashReturns the length in bytes of the output of this hash function.
-
createNew
public StatefulHash createNew()
Description copied from interface:StatefulHashReturns a new instance of this stateful hash function reset to the initial state.- Specified by:
createNewin interfaceStatefulHash- Returns:
- a new instance of this hash in the initial state
-
supportsIncremental
public boolean supportsIncremental()
Description copied from interface:StatefulHashReturns whether this hash function supports incremental hashing. Incremental hashing allows calling theStatefulHash.update(byte[])methods to continue hashing using accumulated state after calling any of the output methods (such asStatefulHash.getBytes()). Non-incremental hash functions require callingStatefulHash.reset()to reinitialize the state between calling an output method and an update method.- Specified by:
supportsIncrementalin interfaceStatefulHash- Returns:
- true if incremental hashing is supported, false if not
-
reset
public void reset()
Description copied from interface:StatefulHashResets this hash function to its initial state. Resetting the state is required for non-incremental hash functions after any output methods have been called.- Specified by:
resetin interfaceStatefulHash
-
updateUnchecked
protected void updateUnchecked(byte[] input, int index, int length)Description copied from class:AbstractStatefulHashUpdates the state of this hash function with the given range of the given input array. The index and length parameters have already been validated.- Specified by:
updateUncheckedin classAbstractStatefulHash- Parameters:
input- the input arrayindex- the starting index of the first input bytelength- the length of the input range
-
getInt
public int getInt()
Description copied from interface:StatefulHashReturns the first four bytes of the output of this hash function as a little-endianint. If the output is less than four bytes, the remaining bytes are set to 0.- Specified by:
getIntin interfaceStatefulHash- Returns:
- the first four output bytes as an int
-
getLong
public long getLong()
Description copied from interface:StatefulHashReturns the first eight bytes of the output of this hash function as a little-endianlong. If the output is less than eight bytes, the remaining bytes are set to 0.- Specified by:
getLongin interfaceStatefulHash- Returns:
- the first eight output bytes as a long
-
asStateless
public StatelessIntHash asStateless()
Description copied from interface:StatefulIntHashReturns an instance of stateless version of this hash function.- Specified by:
asStatelessin interfaceStatefulIntHash- Returns:
- the stateless version of this hash function
-
-