com.thehackerschoice.shagg.algorithms
Interface CheckDigitAlgorithm

All Known Implementing Classes:
Modulus10Algorithm, Modulus11Algorithm, Modulus7Algorithm, Modulus9Algorithm

public interface CheckDigitAlgorithm

Basic method definitions for a check digit algorithm. The last digit of a supplied sequence of digits is verified using the provided check() method. If the algorithm uses weights the optional weights argument is used, otherwise it is set to null.

Version:
$Id: CheckDigitAlgorithm.java,v 1.6 2001/12/13 13:28:25 plasmoid Exp $
Author:
Plasmoid (plasmoid@thehackerschoice.com), THC

Method Summary
 boolean check(int[] sequence, int[] weights)
          Checks if the supplied sequence matches the algorithm.
 int getCheckDigitPosition(int sequence)
          Return the check digit position inside the sequence or -1 if no check digit is taken from the sequence.
 java.lang.String getName()
          Get the name of the implemented check digit algorithm.
 java.lang.String getSymbol()
          Get the symbol of the implemented check digit algorithm.
 boolean usesWeights()
          Checks if the algorithm uses weights for the check digit calculation.
 

Method Detail

check

public boolean check(int[] sequence,
                     int[] weights)
Checks if the supplied sequence matches the algorithm. (Optional) using the supplied weights.
Parameters:
sequence - Integer sequence representing the digits to check, not necessary between 0 and 9.
weights - Weight sequence that can be of any length. If the algorithm doesn't uses weights, null should be supplied.
Returns:
wether sequences matches the algorithm.

usesWeights

public boolean usesWeights()
Checks if the algorithm uses weights for the check digit calculation.
Returns:
true if the algorithm uses weights otherwise false.

getName

public java.lang.String getName()
Get the name of the implemented check digit algorithm.
Returns:
algorithm name

getSymbol

public java.lang.String getSymbol()
Get the symbol of the implemented check digit algorithm. A short synonym should be used to represent the algorithm during the analyse progress, e.g. "10-L" for a Modulus-10 Luhn algorithm,
Returns:
algorithm symbol

getCheckDigitPosition

public int getCheckDigitPosition(int sequence)
Return the check digit position inside the sequence or -1 if no check digit is taken from the sequence.
Parameters:
sequence - Length of integer sequence representing the digits to check, not necessary between 0 and 9.
Returns:
Position of the check digit.