• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package java.util.zip;
19 
20 /**
21  * The interface common to checksum classes such as {@link Adler32} and {@link CRC32}.
22  */
23 public interface Checksum {
24 
25     /**
26      * Returns the current calculated checksum value.
27      *
28      * @return the checksum.
29      */
getValue()30     public long getValue();
31 
32     /**
33      * Resets the checksum value applied before beginning calculations on a new
34      * stream of data.
35      */
reset()36     public void reset();
37 
38     /**
39      * Updates the checksum with the given bytes.
40      *
41      * @param buf
42      *            the byte array from which to read the bytes.
43      * @param off
44      *            the initial position in {@code buf} to read the bytes from.
45      * @param nbytes
46      *            the number of bytes to read from {@code buf}.
47      */
update(byte[] buf, int off, int nbytes)48     public void update(byte[] buf, int off, int nbytes);
49 
50     /**
51      * Updates the checksum value with the given byte.
52      *
53      * @param val
54      *            the byte to update the checksum with.
55      */
update(int val)56     public void update(int val);
57 }
58