|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit
public final class VerhoeffCheckDigit
Verhoeff (Dihedral) Check Digit calculation/validation.
Check digit calculation for numeric codes using a Dihedral Group of order 10.
See Wikipedia - Verhoeff algorithm for more details.
| Field Summary | |
|---|---|
private static int[][] |
D_TABLE
D - multiplication table |
static CheckDigit |
INSTANCE
Singleton Verhoeff Check Digit instance |
private static int[] |
INV_TABLE
inv: inverse table |
private static int[][] |
P_TABLE
P - permutation table |
| Constructor Summary | |
|---|---|
VerhoeffCheckDigit()
|
|
| Method Summary | |
|---|---|
java.lang.String |
calculate(java.lang.String code)
Calculate a Verhoeff Check Digit for a code. |
private int |
calculateChecksum(java.lang.String code,
boolean includesCheckDigit)
Calculate the checksum. |
boolean |
isValid(java.lang.String code)
Validate the Verhoeff Check Digit for a code. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final CheckDigit INSTANCE
private static final int[][] D_TABLE
private static final int[][] P_TABLE
private static final int[] INV_TABLE
| Constructor Detail |
|---|
public VerhoeffCheckDigit()
| Method Detail |
|---|
public boolean isValid(java.lang.String code)
isValid in interface CheckDigitcode - The code to validate
true if the check digit is valid,
otherwise false
public java.lang.String calculate(java.lang.String code)
throws CheckDigitException
calculate in interface CheckDigitcode - The code to calculate the Check Digit for
CheckDigitException - if an error occurs calculating
the check digit for the specified code
private int calculateChecksum(java.lang.String code,
boolean includesCheckDigit)
throws CheckDigitException
code - The code to calculate the checksum for.includesCheckDigit - Whether the code includes the Check Digit or not.
CheckDigitException - if the code contains an invalid character (i.e. not numeric)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||