org.opengts.util
Class FletcherChecksum

java.lang.Object
  extended by org.opengts.util.FletcherChecksum

public class FletcherChecksum
extends java.lang.Object

This class calculates a Fletcher checksum


Constructor Summary
FletcherChecksum()
          Constructor
FletcherChecksum(byte[] b)
          Constructor
 
Method Summary
 byte[] getChecksum()
          Gets the current value of the checksum
 int getChecksumAsInt()
          Returns the current value of the checksum as an integer
 int[] getValues()
          Returns the current values of the checksum accumulator.
 boolean isValid()
          Returns true if the current checksum is valid
static void main(java.lang.String[] argv)
          Command-line entry point (bug/testing purposes)
 void reset()
          Resets the internal Fletcher checksum accumulator
 void runningChecksum(byte b)
          Adds the specified byte to the current running checksum accumulator.
 void runningChecksum(byte[] b)
          Adds the specified byte array to the current running checksum accumulator.
 void runningChecksum(java.lang.String s)
          Adds the bytes from the specified String to the current running checksum accumulator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FletcherChecksum

public FletcherChecksum()
Constructor


FletcherChecksum

public FletcherChecksum(byte[] b)
Constructor

Parameters:
b - The initial byte array
Method Detail

reset

public void reset()
Resets the internal Fletcher checksum accumulator


getValues

public int[] getValues()
Returns the current values of the checksum accumulator.

Returns:
A 2-integer array containing the current values of the checksum accumulator.

isValid

public boolean isValid()
Returns true if the current checksum is valid

Returns:
True if the current checksum is valid, false if invalid.

getChecksum

public byte[] getChecksum()
Gets the current value of the checksum

Returns:
A 2-byte array containing the checksum

getChecksumAsInt

public int getChecksumAsInt()
Returns the current value of the checksum as an integer

Returns:
The current value of the checksum as an integer

runningChecksum

public void runningChecksum(byte b)
Adds the specified byte to the current running checksum accumulator.

Parameters:
b - The byte to add to the current running checksum accumulator.

runningChecksum

public void runningChecksum(byte[] b)
Adds the specified byte array to the current running checksum accumulator.

Parameters:
b - The byte array to add to the current running checksum accumulator.

runningChecksum

public void runningChecksum(java.lang.String s)
Adds the bytes from the specified String to the current running checksum accumulator.

Parameters:
s - The String to add to the current running checksum accumulator.

main

public static void main(java.lang.String[] argv)
Command-line entry point (bug/testing purposes)

Parameters:
argv - The command-line arguments