Class Modulus11TenCheckDigit
java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.Modulus11TenCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
MOD 11,10 module according to ISO/IEC 7064.
See Wikipedia - ISO/IEC_7064 (de) for more details.
This MOD 11,10 module can also be used to validate TIN_DE, TIN_HR, the VATIN_DE and VATIN_HR used in VATINCheckDigit
- Since:
- 1.10.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCalculate a modulus Check Digit for a code which does not yet have one.protected intcalculateModulus(String code, boolean includesCheckDigit) Calculate the modulus for a code.static CheckDigitGets the singleton instance of this validator.booleanValidate a modulus check digit for a code.protected intweightedValue(int charValue, int leftPos, int rightPos) Calculates the weighted value of a character in the code at a specified position.Methods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
getCheckdigitLength, getModulus, sumDigits, toCheckDigit, toInt
-
Method Details
-
getInstance
Gets the singleton instance of this validator.- Returns:
- A singleton instance of the class.
-
weightedValue
protected int weightedValue(int charValue, int leftPos, int rightPos) Calculates the weighted value of a character in the code at a specified position.In MOD 11,10 algorithm there is no weight, so the weighted value is equal to the character value.
- Specified by:
weightedValuein classModulusCheckDigit- Parameters:
charValue- The numeric value of the character.leftPos- The position of the character in the code, counting from left to rightrightPos- The positionof the character in the code, counting from right to left- Returns:
- The weighted value equals to charValue.
-
calculate
Calculate a modulus Check Digit for a code which does not yet have one.- Specified by:
calculatein interfaceCheckDigit- Overrides:
calculatein classModulusCheckDigit- Parameters:
code- The code for which to calculate the Check Digit; the check digit should not be included- Returns:
- The calculated Check Digit
- Throws:
CheckDigitException- if an error occurs calculating the check digit
-
calculateModulus
Calculate the modulus for a code.- Overrides:
calculateModulusin classModulusCheckDigit- Parameters:
code- The code to calculate the modulus for.includesCheckDigit- Whether the code includes the Check Digit or not.- Returns:
- The modulus value
- Throws:
CheckDigitException- if an error occurs calculating the modulus for the specified code
-
isValid
Validate a modulus check digit for a code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classModulusCheckDigit- Parameters:
code- The code to validate- Returns:
trueif the check digit is valid, otherwisefalse
-