Package com.scurrilous.circe.impl
Class IncrementalIntStatefulHash
- java.lang.Object
-
- com.scurrilous.circe.impl.AbstractStatefulHash
-
- com.scurrilous.circe.impl.IncrementalIntStatefulHash
-
- All Implemented Interfaces:
Hash
,StatefulHash
,StatefulIntHash
class IncrementalIntStatefulHash extends AbstractStatefulHash implements StatefulIntHash
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
current
(package private) AbstractIncrementalIntHash
stateless
-
Constructor Summary
Constructors Constructor Description IncrementalIntStatefulHash(AbstractIncrementalIntHash stateless)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
algorithm()
Returns the canonical name of this hash algorithm.StatelessIntHash
asStateless()
Returns an instance of stateless version of this hash function.StatefulHash
createNew()
Returns a new instance of this stateful hash function reset to the initial state.int
getInt()
Returns the first four bytes of the output of this hash function as a little-endianint
.long
getLong()
Returns the first eight bytes of the output of this hash function as a little-endianlong
.int
length()
Returns the length in bytes of the output of this hash function.void
reset()
Resets this hash function to its initial state.boolean
supportsIncremental()
Returns whether this hash function supports incremental hashing.boolean
supportsUnsafe()
Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such asStatefulHash.update(long, long)
,StatelessIntHash.calculate(long, long)
, orIncrementalIntHash.resume(int, long, long)
.void
update(long address, long length)
Updates the state of this hash function with memory with the given address and length.void
update(java.nio.ByteBuffer input)
Updates the state of this hash function with the remaining contents of the given input buffer.protected void
updateUnchecked(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, update, update, writeBytes
-
-
-
-
Field Detail
-
stateless
final AbstractIncrementalIntHash stateless
-
current
int current
-
-
Constructor Detail
-
IncrementalIntStatefulHash
IncrementalIntStatefulHash(AbstractIncrementalIntHash stateless)
-
-
Method Detail
-
asStateless
public StatelessIntHash asStateless()
Description copied from interface:StatefulIntHash
Returns an instance of stateless version of this hash function.- Specified by:
asStateless
in interfaceStatefulIntHash
- Returns:
- the stateless version of this hash function
-
algorithm
public java.lang.String algorithm()
Description copied from interface:Hash
Returns the canonical name of this hash algorithm.
-
length
public int length()
Description copied from interface:Hash
Returns the length in bytes of the output of this hash function.
-
supportsUnsafe
public boolean supportsUnsafe()
Description copied from interface:Hash
Returns whether this hash function supports unsafe access to arbitrary memory addresses using methods such asStatefulHash.update(long, long)
,StatelessIntHash.calculate(long, long)
, orIncrementalIntHash.resume(int, long, long)
. Such functions are generally implemented in native code.- Specified by:
supportsUnsafe
in interfaceHash
- Overrides:
supportsUnsafe
in classAbstractStatefulHash
- Returns:
- true if unsafe access is supported, false if not
-
createNew
public StatefulHash createNew()
Description copied from interface:StatefulHash
Returns a new instance of this stateful hash function reset to the initial state.- Specified by:
createNew
in interfaceStatefulHash
- Returns:
- a new instance of this hash in the initial state
-
supportsIncremental
public boolean supportsIncremental()
Description copied from interface:StatefulHash
Returns 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:
supportsIncremental
in interfaceStatefulHash
- Returns:
- true if incremental hashing is supported, false if not
-
reset
public void reset()
Description copied from interface:StatefulHash
Resets 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:
reset
in interfaceStatefulHash
-
update
public void update(java.nio.ByteBuffer input)
Description copied from interface:StatefulHash
Updates the state of this hash function with the remaining contents of the given input buffer. This method leaves the buffer position at the limit.- Specified by:
update
in interfaceStatefulHash
- Overrides:
update
in classAbstractStatefulHash
- Parameters:
input
- the input buffer
-
update
public void update(long address, long length)
Description copied from interface:StatefulHash
Updates the state of this hash function with memory with the given address and length. The arguments are generally not checked in any way and will likely lead to a VM crash or undefined results if invalid.- Specified by:
update
in interfaceStatefulHash
- Overrides:
update
in classAbstractStatefulHash
- Parameters:
address
- the base address of the inputlength
- the length of the input- See Also:
Hash.supportsUnsafe()
-
updateUnchecked
protected void updateUnchecked(byte[] input, int index, int length)
Description copied from class:AbstractStatefulHash
Updates 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:
updateUnchecked
in 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:StatefulHash
Returns 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:
getInt
in interfaceStatefulHash
- Returns:
- the first four output bytes as an int
-
getLong
public long getLong()
Description copied from interface:StatefulHash
Returns 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:
getLong
in interfaceStatefulHash
- Returns:
- the first eight output bytes as a long
-
-