javaFlacEncoder
Class CRC8

java.lang.Object
  extended by javaFlacEncoder.CRC8

public class CRC8
extends java.lang.Object

Class to calculate a CRC8 checksum.

Author:
Preston Lacey

Field Summary
static int DEBUG_LEV
          For Debugging: Higher level equals more debug statements
 
Constructor Summary
CRC8()
          Constructor.
 
Method Summary
 byte checksum()
          Finalize the checksum, and return the value.
 void reset()
          Resets all stored data, preparing object for a new checksum.
 byte updateCRC8(byte[] inSet, int start, int end)
          Add data to the crc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_LEV

public static int DEBUG_LEV
For Debugging: Higher level equals more debug statements

Constructor Detail

CRC8

public CRC8()
Constructor. Creates a CRC8 object that is ready to be used. Next step would be to call updateCRC8 with appropriate data.

Method Detail

updateCRC8

public byte updateCRC8(byte[] inSet,
                       int start,
                       int end)
Add data to the crc. Immediately creates checksum on given data. Can be called multiple times as it won't finalize the checksum until the method checksum() is called.

Parameters:
inSet - Array holding data to checksum.
start - Index of array holding first element
end - Index to stop at. Last index used will be end-1.
Returns:
intermediate result of checksum to this point. This is *not* a finalized result, as non-summed data must remain in workingCRC8 until checksum() is called.

checksum

public byte checksum()
Finalize the checksum, and return the value. After this is called, you must call reset() before attempting a new checksum.

Returns:
finalized checksum.

reset

public void reset()
Resets all stored data, preparing object for a new checksum.