Class Modulus11FINCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
11-X FIN Numbers are a alphanumeric code. The last (check) digit can have a value of "X".
Check digit calculation is based on modulus 11 with digits being weighted based by their position, from right to left. If the check digit is calculated as "10" it is converted to "X".
See Wikipedia (de) for more details. And Berechnung der Prüfziffer zur FIN nach dem Modulo-11-Verfahren in kba.de.
- Since:
- 2.10.5
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CheckDigitGets the singleton instance of this class.booleanValidate a modulus check digit for a code.protected inttoInt(char character, int leftPos, int rightPos) Convert a character at a specified position to an integer value.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.Modulus11XCheckDigit
toCheckDigitMethods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
calculate, calculateModulus, getCheckdigitLength, getModulus, sumDigits
-
Method Details
-
getInstance
Gets the singleton instance of this class.- Returns:
- A singleton instance of the class.
-
toInt
Convert a character at a specified position to an integer value.
Character 'X' check digit converted to 10.
Override to handle character FIN mapping.
- Overrides:
toIntin classModulus11XCheckDigit- Parameters:
character- The character to convert.leftPos- The position of the character in the code, counting from left to rightrightPos- The position of the character in the code, counting from right to left- Returns:
- The integer value of the character.
- Throws:
CheckDigitException- if an error occurs.
-
weightedValue
Calculates the weighted value of a character in the code at a specified position.Some modulus routines weight the value of a character depending on its position in the code (e.g. ISBN-10), while others use different weighting factors for odd/even positions (e.g. EAN or Luhn). Implement the appropriate mechanism required by overriding this method.
Implement to handle weights as right position.
Override to handle weights as right position.
- Overrides:
weightedValuein classModulus11iWeightCheckDigit- Parameters:
charValue- The numeric value of the characterleftPos- The position of the character in the code, counting from left to rightrightPos- The position of the character in the code, counting from right to left- Returns:
- The weighted value of the character
- Throws:
CheckDigitException- if an error occurs calculating the weighted value
-
isValid
Validate a modulus check digit for a code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classModulus11iWeightCheckDigit- Parameters:
code- The code to validate- Returns:
trueif the check digit is valid, otherwisefalse
-