FileDocCategorySizeDatePackage
CRC.javaAPI DocApache Ant 1.705737Wed Dec 13 06:16:20 GMT 2006org.apache.tools.bzip2

CRC

public final class CRC extends Object
A simple class the hold and calculate the CRC for sanity checking of the data.

Fields Summary
static final int[]
crc32Table
int
globalCrc
Constructors Summary
CRC()


     
        initialiseCRC();
    
Methods Summary
intgetFinalCRC()

        return ~globalCrc;
    
intgetGlobalCRC()

        return globalCrc;
    
voidinitialiseCRC()

        globalCrc = 0xffffffff;
    
voidsetGlobalCRC(int newCrc)

        globalCrc = newCrc;
    
voidupdateCRC(int inCh)

        int temp = (globalCrc >> 24) ^ inCh;
        if (temp < 0) {
            temp = 256 + temp;
        }
        globalCrc = (globalCrc << 8) ^ CRC.crc32Table[temp];
    
voidupdateCRC(int inCh, int repeat)

        int globalCrcShadow = this.globalCrc;
        while (repeat-- > 0) {
            int temp = (globalCrcShadow >> 24) ^ inCh;
            globalCrcShadow = (globalCrcShadow << 8) ^ crc32Table[(temp >= 0)
                                                      ? temp
                                                      : (temp + 256)];
        }
        this.globalCrc = globalCrcShadow;