1 package net.jpountz.xxhash;
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 final class StreamingXXHash32JNI extends StreamingXXHash32 {
20 static class Factory implements StreamingXXHash32.Factory {
22 public static final StreamingXXHash32.Factory INSTANCE = new Factory();
25 public StreamingXXHash32 newStreamingHash(int seed) {
26 return new StreamingXXHash32JNI(seed);
33 StreamingXXHash32JNI(int seed) {
35 state = XXHashJNI.XXH32_init(seed);
38 private void checkState() {
40 throw new AssertionError("Already finalized");
47 XXHashJNI.XXH32_free(state);
48 state = XXHashJNI.XXH32_init(seed);
52 public int getValue() {
54 return XXHashJNI.XXH32_digest(state);
58 public void update(byte[] bytes, int off, int len) {
60 XXHashJNI.XXH32_update(state, bytes, off, len);
64 protected void finalize() throws Throwable {
67 XXHashJNI.XXH32_free(state);