com.thehackerschoice.shagg.algorithms
Class Modulus7Algorithm
java.lang.Object
|
+--com.thehackerschoice.shagg.algorithms.Modulus7Algorithm
- public class Modulus7Algorithm
- extends java.lang.Object
- implements CheckDigitAlgorithm
Implementation of the Modulus 7/9 Algorithm. Both algorithms have been
used in the hardware implementation of print devices in the early days of
the computer. The algorithms are seldomly used due to the fact that they
interpret the sequence of digits as number.
The Modulus 7/9 Algorithm interpret the supplied sequence of digits as
an integer number and the check digit is the result of the Modulus 7
respectively the Modulus 9 operation.
- Version:
- $Id: Modulus7Algorithm.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 Modulus 7 Algorithm. |
int |
getCheckDigitPosition(int sequence)
Return the check digit position inside the sequence. |
java.lang.String |
getName()
Get the name of the implemented check digit algorithm, Modulus 7. |
java.lang.String |
getSymbol()
Get the symbol of the implemented check digit algorithm. |
boolean |
usesWeights()
The Modulus 7 Algorithm doesn't use weights. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
Modulus7Algorithm
public Modulus7Algorithm()
getName
public java.lang.String getName()
- Get the name of the implemented check digit algorithm, Modulus 7.
- Specified by:
- getName in interface CheckDigitAlgorithm
- Returns:
- algorithm name.
getSymbol
public java.lang.String getSymbol()
- Get the symbol of the implemented check digit algorithm. In this
case "7" for Modulus 7.
- Specified by:
- getSymbol in interface CheckDigitAlgorithm
- Tags copied from interface: CheckDigitAlgorithm
- Returns:
- algorithm symbol
check
public boolean check(int[] sequence,
int[] weights)
- Checks if the supplied sequence matches the Modulus 7 Algorithm.
Modulus 7 doesn't use any weights.
- Specified by:
- check in interface CheckDigitAlgorithm
- Parameters:
sequence
- Integer sequence representing the digits to check,
not necessary between 0 and 9.weights
- Must be null.- Returns:
- wether sequences matches the algorithm.
usesWeights
public boolean usesWeights()
- The Modulus 7 Algorithm doesn't use weights.
- Specified by:
- usesWeights in interface CheckDigitAlgorithm
- Returns:
- false
getCheckDigitPosition
public int getCheckDigitPosition(int sequence)
- Return the check digit position inside the sequence. Modulus 7 uses
the last digit.
- Specified by:
- getCheckDigitPosition in interface CheckDigitAlgorithm
- Parameters:
sequence
- Length of the integer sequence representing the digits
to check, not necessary between 0 and 9.- Returns:
- Position of the check digit.