public interface Checksum
An interface representing a data checksum.
- Since:
- 1.1
- 
Method SummaryModifier and TypeMethodDescriptionlonggetValue()Returns the current checksum value.voidreset()Resets the checksum to its initial value.default voidupdate(byte[] b) Updates the current checksum with the specified array of bytes.voidupdate(byte[] b, int off, int len) Updates the current checksum with the specified array of bytes.voidupdate(int b) Updates the current checksum with the specified byte.default voidupdate(ByteBuffer buffer) Updates the current checksum with the bytes from the specified buffer.
- 
Method Details- 
updatevoid update(int b) Updates the current checksum with the specified byte.- Parameters:
- b- the byte to update the checksum with
 
- 
updatedefault void update(byte[] b) Updates the current checksum with the specified array of bytes.- Implementation Requirements:
- This default implementation is equal to calling
 update(b, 0, b.length).
- Parameters:
- b- the array of bytes to update the checksum with
- Throws:
- NullPointerException- if- bis- null
- Since:
- 9
 
- 
updatevoid update(byte[] b, int off, int len) Updates the current checksum with the specified array of bytes.- Parameters:
- b- the byte array to update the checksum with
- off- the start offset of the data
- len- the number of bytes to use for the update
 
- 
updateUpdates the current checksum with the bytes from the specified buffer. The checksum is updated with the remaining bytes in the buffer, starting at the buffer's position. Upon return, the buffer's position will be updated to its limit; its limit will not have been changed.- API Note:
- For best performance with DirectByteBuffer and other ByteBuffer implementations without a backing array implementers of this interface should override this method.
- Implementation Requirements:
- The default implementation has the following behavior.
 For ByteBuffers backed by an accessible byte array.
 For ByteBuffers not backed by an accessible byte array.update(buffer.array(), buffer.position() + buffer.arrayOffset(), buffer.remaining());byte[] b = new byte[Math.min(buffer.remaining(), 4096)]; while (buffer.hasRemaining()) { int length = Math.min(buffer.remaining(), b.length); buffer.get(b, 0, length); update(b, 0, length); }
- Parameters:
- buffer- the ByteBuffer to update the checksum with
- Throws:
- NullPointerException- if- bufferis- null
- Since:
- 9
 
- 
getValuelong getValue()Returns the current checksum value.- Returns:
- the current checksum value
 
- 
resetvoid reset()Resets the checksum to its initial value.
 
-