Class Modulus11XiLeftCheckDigit

All Implemented Interfaces:
Serializable, CheckDigit

public final class Modulus11XiLeftCheckDigit extends Modulus11iLeftCheckDigit
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 can have a value of "X" (10).

This module is used to calculate EC index numbers. EC Index Numbers are a numeric code except for the last (check) digit which can have a value of "X".
Note that these module do not validate the input for syntax. Such validation is performed by the ECIndexNumberValidator

Since:
1.9.0
See Also:
  • Method Details

    • getInstance

      public static CheckDigit 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) 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.

      Override to handle weights as left position.

      Overrides:
      weightedValue in class Modulus11iLeftCheckDigit
      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.

      Override to handle charValue X.

      Overrides:
      toCheckDigit in class Modulus11iLeftCheckDigit
      Parameters:
      charValue - The integer value of the character
      Returns:
      The converted character
      Throws:
      CheckDigitException - if integer character value doesn't represent a numeric character