org.thc.shagg.algorithms
Class Modulus9Algorithm
java.lang.Object
|
+--org.thc.shagg.algorithms.Modulus9Algorithm
- All Implemented Interfaces:
- CheckDigitAlgorithm
- public class Modulus9Algorithm
- 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: Modulus9Algorithm.java,v 1.7 2003/07/18 10:08:05 plasmoid Exp $
- Author:
- Plasmoid (plasmoid@thc.org),
THC
Method Summary |
boolean |
check(int[] sequence,
int[] weights)
Checks if the supplied sequence matches the Modulus 9 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 9. |
java.lang.String |
getSymbol()
Get the symbol of the implemented check digit algorithm. |
boolean |
usesWeights()
The Modulus 9 Algorithm doesn't use weights. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Modulus9Algorithm
public Modulus9Algorithm()
getName
public java.lang.String getName()
- Get the name of the implemented check digit algorithm, Modulus 9.
- 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 "9" for Modulus 9.
- Specified by:
getSymbol
in interface CheckDigitAlgorithm
- Following copied from interface:
org.thc.shagg.algorithms.CheckDigitAlgorithm
- Returns:
- algorithm symbol
check
public boolean check(int[] sequence,
int[] weights)
- Checks if the supplied sequence matches the Modulus 9 Algorithm.
Modulus 9 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 9 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 9 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.