Class Modulus11iLeftCheckDigit

All Implemented Interfaces:
Serializable, CheckDigit
Direct Known Subclasses:
Modulus11iTwoPhaseCheckDigit, Modulus11XiLeftCheckDigit, TidHUCheckDigit

public class Modulus11iLeftCheckDigit extends Modulus11iBSNCheckDigit
Check digit calculation based on modulus 11 and weighs based on the digit position.

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 Details

    • getInstance

      public static CheckDigit getInstance()
      Gets the singleton instance of this class.
      Returns:
      A singleton instance of the class.
    • weightedValue

      protected int weightedValue(int charValue, int leftPos, int rightPos) throws CheckDigitException
      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:
      weightedValue in class Modulus11iWeightCheckDigit
      Parameters:
      charValue - The numeric value of the character
      leftPos - The position of the character in the code, counting from left to right
      rightPos - 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

      protected String toCheckDigit(int charValue) throws CheckDigitException
      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:
      toCheckDigit in class Modulus11iWeightCheckDigit
      Parameters:
      charValue - The integer value of the character
      Returns:
      The converted character
      Throws:
      CheckDigitException - if integer character value doesn't represent a numeric character