FileDocCategorySizeDatePackage
Adler32.javaAPI DocAndroid 1.5 API3227Wed May 06 22:41:02 BST 2009java.util.zip

Adler32

public class Adler32 extends Object implements Checksum
The Adler-32 class is used to compute the {@code Adler32} checksum from a set of data. Compared to the CRC-32 algorithm it trades reliabilty for speed. Refer to RFC 1950 for the specification.
see
CRC32
since
Android 1.0

Fields Summary
private long
adler
Constructors Summary
Methods Summary
public longgetValue()
Returns the {@code Adler32} checksum for all input received.

return
The checksum for this instance.
since
Android 1.0


                            
       
        return adler;
    
public voidreset()
Reset this instance to its initial checksum.

since
Android 1.0

        adler = 1;
    
public voidupdate(int i)
Update this {@code Adler32} checksum with the single byte provided as argument.

param
i the byte to update checksum with.
since
Android 1.0

        adler = updateByteImpl(i, adler);
    
public voidupdate(byte[] buf)
Update this {@code Adler32} checksum using the contents of {@code buf}.

param
buf bytes to update checksum with.
since
Android 1.0

        update(buf, 0, buf.length);
    
public voidupdate(byte[] buf, int off, int nbytes)
Update this {@code Adler32} checksum with the contents of {@code buf}, starting from the offset provided and reading n bytes of data.

param
buf buffer to obtain data from.
param
off offset in {@code buf} to start reading from.
param
nbytes number of bytes from {@code buf} to use.
throws
ArrayIndexOutOfBoundsException if {@code offset > buf.length} or {@code nbytes} is negative or {@code offset + nbytes > buf.length}.
since
Android 1.0

        // avoid int overflow, check null buf
        if (off <= buf.length && nbytes >= 0 && off >= 0
                && buf.length - off >= nbytes) {
            adler = updateImpl(buf, off, nbytes, adler);
        } else {
            throw new ArrayIndexOutOfBoundsException();
        }
    
private native longupdateByteImpl(int val, long adler1)

private native longupdateImpl(byte[] buf, int off, int nbytes, long adler1)