1 |
/* Checksum.java - Interface to compute a data checksum |
/* java.util.zip.Checksum |
2 |
Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
Copyright (C) 2001 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of Jazzlib. |
5 |
|
|
6 |
GNU Classpath is free software; you can redistribute it and/or modify |
Jazzlib is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
Jazzlib is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
General Public License for more details. |
General Public License for more details. |
26 |
|
|
27 |
package java.util.zip; |
package java.util.zip; |
28 |
|
|
|
/* |
|
|
* Written using on-line Java Platform 1.2 API Specification, as well |
|
|
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). |
|
|
* Status: Believed complete and correct. |
|
|
*/ |
|
|
|
|
29 |
/** |
/** |
30 |
* Interface to compute a data checksum used by checked input/output streams. |
* This is an interface for calculating checksums. |
|
* A data checksum can be updated by one byte or with a byte array. After each |
|
|
* update the value of the current checksum can be returned by calling |
|
|
* <code>getValue</code>. The complete checksum object can also be reset |
|
|
* so it can be used again with new data. |
|
31 |
* |
* |
32 |
* @see CheckedInputStream |
* @author Jochen Hoenicke |
33 |
* @see CheckedOutputStream |
* @since JDK 1.1 |
|
* |
|
|
* @author Per Bothner |
|
|
* @date January 9, 1999. |
|
34 |
*/ |
*/ |
35 |
public interface Checksum |
public interface Checksum { |
36 |
{ |
|
37 |
/** |
/** |
38 |
* Returns the data checksum computed so far. |
* Updates the checksum with the byte b. |
39 |
|
* @param b the byte, only the lower 8 bits are used. |
40 |
*/ |
*/ |
41 |
public long getValue (); |
public void update(int b); |
42 |
|
|
43 |
/** |
/** |
44 |
* Resets the data checksum as if no update was ever called. |
* Calculates the checksum of the given part of the byte array, updating |
45 |
|
* its current value. |
46 |
|
* @param b an array of bytes |
47 |
|
* @param off the offset into the array. |
48 |
|
* @param len the length. |
49 |
*/ |
*/ |
50 |
public void reset (); |
public void update(byte[] b, int off, int len); |
51 |
|
|
52 |
/** |
/** |
53 |
* Adds one byte to the data checksum. |
* Resets the checksum to the initial value. |
|
* |
|
|
* @param bval the data value to add. The high byte of the int is ignored. |
|
54 |
*/ |
*/ |
55 |
public void update (int bval); |
public void reset(); |
56 |
|
|
57 |
/** |
/** |
58 |
* Adds the byte array to the data checksum. |
* Gets the current checksum value. |
|
* |
|
|
* @param buf the buffer which contains the data |
|
|
* @param off the offset in the buffer where the data starts |
|
|
* @param len the length of the data |
|
59 |
*/ |
*/ |
60 |
public void update (byte[] buf, int off, int len); |
public long getValue(); |
61 |
} |
} |
62 |
|
|