org.apache.commons.validator.routines.checkdigit
Class VerhoeffCheckDigit

java.lang.Object
  extended by org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit
All Implemented Interfaces:
Serializable, CheckDigit

public final class VerhoeffCheckDigit
extends Object
implements CheckDigit, Serializable

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:
Validator 1.4
Version:
$Revision: 1227719 $ $Date: 2012-01-05 18:45:51 +0100 (Thu, 05 Jan 2012) $
See Also:
Serialized Form

Field Summary
static CheckDigit VERHOEFF_CHECK_DIGIT
          Singleton Verhoeff Check Digit instance
 
Constructor Summary
VerhoeffCheckDigit()
           
 
Method Summary
 String calculate(String code)
          Calculate a Verhoeff Check Digit for a code.
 boolean isValid(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

VERHOEFF_CHECK_DIGIT

public static final CheckDigit VERHOEFF_CHECK_DIGIT
Singleton Verhoeff Check Digit instance

Constructor Detail

VerhoeffCheckDigit

public VerhoeffCheckDigit()
Method Detail

isValid

public boolean isValid(String code)
Validate the Verhoeff Check Digit for a code.

Specified by:
isValid in interface CheckDigit
Parameters:
code - The code to validate
Returns:
true if the check digit is valid, otherwise false

calculate

public String calculate(String code)
                 throws CheckDigitException
Calculate a Verhoeff Check Digit for a code.

Specified by:
calculate in interface CheckDigit
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


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.