Class Modulus11iLeftCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
- Direct Known Subclasses:
Modulus11iTwoPhaseCheckDigit,Modulus11XiLeftCheckDigit,TidHUCheckDigit
Digits are weighted based by their position, from left to right with the first digit being weighted 1, the second 2 and so on. Check digit cannot be 10.
This module is used to calculate Hungarian TIN check digits „adóazonosító jel“. See Wikipedia (hu) for more details.
- Since:
- 2.10.6
- Author:
- EUG https://github.com/homebeaver
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CheckDigitGets the singleton instance of this class.protected StringtoCheckDigit(int charValue) Convert an integer value to a check digit.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.Modulus11iBSNCheckDigit
calculateMethods inherited from class org.apache.commons.validator.routines.checkdigit.Modulus11iWeightCheckDigit
isValidMethods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
calculateModulus, getCheckdigitLength, getModulus, sumDigits, toInt
-
Method Details
-
getInstance
Gets the singleton instance of this class.- Returns:
- A singleton instance of the class.
-
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 1 2 3 4 5 6 7 8 9, then 1 2 3 ... as left 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
-
toCheckDigit
Convert an integer value to a check digit.Note: this implementation only handles single-digit numeric values For non-numeric characters, override this method to provide integer-->character conversion.
Override to handle charValue 10.
Override to handle charValue 10 as invalid check digit value.
- Overrides:
toCheckDigitin classModulus11iWeightCheckDigit- Parameters:
charValue- The integer value of the character- Returns:
- The converted character
- Throws:
CheckDigitException- if integer character value doesn't represent a numeric character
-