org.bolet.jgz
Class CRC

java.lang.Object
  extended by org.bolet.jgz.CRC

public final class CRC
extends java.lang.Object

This class contains helper method for computing CRC checksums over some data. The CRC has a 32-bit state, which begins with the "all-ones" value (see the START constant). The CRC result, once all data bytes have been processed, is the bitwise inverse of the state.


Field Summary
static int START
          The initial value for a CRC (this is the "all-one" constant).
 
Method Summary
static int updateCRC(int crc, byte[] buf)
          Update a CRC value with several data bytes
static int updateCRC(int crc, byte[] buf, int off, int len)
          Update a CRC value with several data bytes
static int updateCRC(int crc, int v)
          Update a CRC value with a data byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START

public static final int START
The initial value for a CRC (this is the "all-one" constant).

See Also:
Constant Field Values
Method Detail

updateCRC

public static int updateCRC(int crc,
                            int v)
Update a CRC value with a data byte.

Parameters:
crc - the CRC value
v - the data byte (between 0 and 255)
Returns:
the new CRC value

updateCRC

public static int updateCRC(int crc,
                            byte[] buf)
Update a CRC value with several data bytes

Parameters:
crc - the CRC value
buf - the data bytes
Returns:
the new CRC value

updateCRC

public static int updateCRC(int crc,
                            byte[] buf,
                            int off,
                            int len)
Update a CRC value with several data bytes

Parameters:
crc - the CRC value
buf - the data bytes
off - the data bytes offset
len - the data bytes length (in bytes)
Returns:
the new CRC value