1 7 8 package java.util.zip; 9 10 19 public 20 class Adler32 implements Checksum { 21 private int adler = 1; 22 23 26 public Adler32() { 27 } 28 29 30 35 public void update(int b) { 36 adler = update(adler, b); 37 } 38 39 42 public void update(byte[] b, int off, int len) { 43 if (b == null) { 44 throw new NullPointerException (); 45 } 46 if (off < 0 || len < 0 || off > b.length - len) { 47 throw new ArrayIndexOutOfBoundsException (); 48 } 49 adler = updateBytes(adler, b, off, len); 50 } 51 52 55 public void update(byte[] b) { 56 adler = updateBytes(adler, b, 0, b.length); 57 } 58 59 62 public void reset() { 63 adler = 1; 64 } 65 66 69 public long getValue() { 70 return (long)adler & 0xffffffffL; 71 } 72 73 private native static int update(int adler, int b); 74 private native static int updateBytes(int adler, byte[] b, int off, 75 int len); 76 } 77 | Popular Tags |