Class VerhoeffCheckDigit
java.lang.Object
org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit
- All Implemented Interfaces:
Serializable, CheckDigit
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.
- Since:
- 1.4
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CheckDigitSingleton Verhoeff Check Digit instance. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
VERHOEFF_CHECK_DIGIT
Singleton Verhoeff Check Digit instance.
-
-
Constructor Details
-
VerhoeffCheckDigit
public VerhoeffCheckDigit()Constructs a new instance.
-
-
Method Details
-
calculate
Calculate a Verhoeff Check Digit for a code.- Specified by:
calculatein interfaceCheckDigit- Parameters:
code- The code to calculate the Check Digit for.- Returns:
- The calculated Check Digit.
- Throws:
CheckDigitException- if an error occurs calculating the check digit for the specified code.
-
isValid
Validate the Verhoeff Check Digit for a code.- Specified by:
isValidin interfaceCheckDigit- Parameters:
code- The code to validate.- Returns:
trueif the check digit is valid, otherwisefalse.
-