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

CRC32

public class CRC32 extends Object implements Checksum
The CRC32 class is used to compute a CRC32 checksum from data provided as input value.
since
Android 1.0

Fields Summary
private long
crc
long
tbytes
Constructors Summary
Methods Summary
public longgetValue()
Returns the CRC32 checksum for all input received.

return
The checksum for this instance.
since
Android 1.0


                           
       
        return crc;
    
public voidreset()
Resets the CRC32 checksum to it initial state.

since
Android 1.0

        tbytes = crc = 0;

    
public voidupdate(int val)
Updates this checksum with the byte value provided as integer.

param
val represents the byte to update the checksum.
since
Android 1.0

        crc = updateByteImpl((byte) val, crc);
    
public voidupdate(byte[] buf)
Updates this checksum with the bytes contained in buffer {@code buf}.

param
buf the buffer holding the data to update the checksum with.
since
Android 1.0

        update(buf, 0, buf.length);
    
public voidupdate(byte[] buf, int off, int nbytes)
Updates this checksum with n bytes of data obtained from buffer {@code buf}, starting at offset {@code off}.

param
buf the buffer to update the checksum.
param
off the offset in {@code buf} to obtain data from.
param
nbytes the number of bytes to read from {@code buf}.
since
Android 1.0

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

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