Hasher; handles accumulating data until an
entire "chunk" (of implementation-dependent length) is ready to be hashed.
| Modifier and Type | Field and Description |
|---|---|
| private final ByteBuffer | buffer
Buffer via which we pass data to the hash algorithm (the implementor) |
| private final int | bufferSize
Number of bytes to be filled before process() invocation(s). |
| private final int | chunkSize
Number of bytes processed per process() invocation. |
| Access | Constructor and Description |
|---|---|
| protected | AbstractStreamingHasher(int
the number of bytes available per chunkSize)process(ByteBuffer) invocation;
must be at least 4Constructor for use by subclasses. |
| protected | AbstractStreamingHasher(int
the number of bytes available per chunkSize, int process(ByteBuffer) invocation;
must be at least 4the size of the internal buffer. Must be a multiple of chunkSize bufferSize)Constructor for use by subclasses. |
| Modifier and Type | Method and Description |
|---|---|
| public final HashCode | hash()
Implements com. |
| protected abstract HashCode | |
| private void | |
| private void | |
| protected abstract void | |
| protected void | processRemaining(ByteBuffer bb)
This is invoked for the last bytes of the input, which are not enough to fill a whole chunk. |
| public final Hasher | |
| public final Hasher | putBytes(byte[]
a byte array bytes, int the start offset in the array off, int the number of bytes to write len)Overrides com. Implements com. |
| public final Hasher | putBytes(ByteBuffer
a byte buffer readBuffer)Overrides com. Implements com. |
| private Hasher | |
| public final Hasher | putChar(char c)
Overrides com. Implements com. |
| public final Hasher | putInt(int i)
Overrides com. Implements com. |
| public final Hasher | putLong(long l)
Overrides com. Implements com. |
| public final Hasher | putShort(short s)
Overrides com. Implements com. |
| buffer | back to summary |
|---|---|
| private final ByteBuffer buffer Buffer via which we pass data to the hash algorithm (the implementor) | |
| bufferSize | back to summary |
|---|---|
| private final int bufferSize Number of bytes to be filled before process() invocation(s). | |
| chunkSize | back to summary |
|---|---|
| private final int chunkSize Number of bytes processed per process() invocation. | |
| AbstractStreamingHasher | back to summary |
|---|---|
| protected AbstractStreamingHasher(int chunkSize) Constructor for use by subclasses. This hasher instance will process chunks of the specified size.
| |
| AbstractStreamingHasher | back to summary |
|---|---|
| protected AbstractStreamingHasher(int chunkSize, int bufferSize) Constructor for use by subclasses. This hasher instance will process chunks of the specified
size, using an internal buffer of
| |
| hash | back to summary |
|---|---|
| public final HashCode hash() Implements com. Doc from com. 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.
| |
| makeHash | back to summary |
|---|---|
| protected abstract HashCode makeHash() Computes a hash code based on the data that have been provided to this hasher. This is called
after all chunks are handled with | |
| munch | back to summary |
|---|---|
| private void munch() | |
| munchIfFull | back to summary |
|---|---|
| private void munchIfFull() | |
| process | back to summary |
|---|---|
| protected abstract void process(ByteBuffer bb) Processes the available bytes of the buffer (at most | |
| processRemaining | back to summary |
|---|---|
| protected void processRemaining(ByteBuffer bb) This is invoked for the last bytes of the input, which are not enough to fill a whole chunk.
The passed This implementation simply pads with zeros and delegates to | |
| putByte | back to summary |
|---|---|
| public final Hasher putByte(byte b) Implements com. Doc from com. Puts a byte into this sink.
| |
| putBytes | back to summary |
|---|---|
| public final Hasher putBytes(byte[] bytes, int off, int len) Overrides com. Implements com. Doc from com. Puts a chunk of an array of bytes into this sink.
| |
| putBytes | back to summary |
|---|---|
| public final Hasher putBytes(ByteBuffer readBuffer) Overrides com. Implements com. Doc from com. Puts the remaining bytes of a byte buffer into this sink.
| |
| putBytesInternal | back to summary |
|---|---|
private Hasher putBytesInternal(ByteBuffer readBuffer)
| |
| putChar | back to summary |
|---|---|
| public final Hasher putChar(char c) Overrides com. Implements com. Doc from com. Puts a character into this sink.
| |
| putInt | back to summary |
|---|---|
| public final Hasher putInt(int i) Overrides com. Implements com. Doc from com. Puts an int into this sink.
| |
| putLong | back to summary |
|---|---|
| public final Hasher putLong(long l) Overrides com. Implements com. Doc from com. Puts a long into this sink.
| |
| putShort | back to summary |
|---|---|
| public final Hasher putShort(short s) Overrides com. Implements com. Doc from com. Puts a short into this sink.
| |