com.thehackerschoice.shagg.algorithms
Class Modulus11Algorithm
java.lang.Object
|
+--com.thehackerschoice.shagg.algorithms.Modulus11Algorithm
- public class Modulus11Algorithm
- extends java.lang.Object
- implements CheckDigitAlgorithm
Implementation of the Modulus 11 Algorithm commonly used in the ISBN and
EAN numbers. The digits are multiplied with the reversed index and summed
up. 11 subtracted from the modulus 11 of the sum S is the final check
digit C. If the modulus 11 operation results 0, the check digit needs to
be zero instead of 11.
1 2 3 4 ... 9 C
* * * * *
9 8 7 6 ... 1
+ + + ...+ -> S
11 - (S mod 11) = C
- Version:
- $Id: Modulus11Algorithm.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 11 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 11. |
java.lang.String |
getSymbol()
Get the symbol of the implemented check digit algorithm. |
boolean |
usesWeights()
The Modulus 11 Algorithm doesn't use weights. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
Modulus11Algorithm
public Modulus11Algorithm()
getName
public java.lang.String getName()
- Get the name of the implemented check digit algorithm, Modulus 11.
- 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 "11" for Modulus 11.
- 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 11 Algorithm.
Modulus 11 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 11 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 11 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.