Class Modulus11XCheckDigit

All Implemented Interfaces:
Serializable, CheckDigit
Direct Known Subclasses:
ISBN10CheckDigit, ISSNCheckDigit, Mod11XISBN10CheckDigit, Modulus11FINCheckDigit

public class Modulus11XCheckDigit extends Modulus11iWeightCheckDigit
Modulus 11-X module for Check Digit calculation/validation of 11-X Numbers.

11-X Numbers are a numeric code except for the last (check) digit which 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 (the default) with the right most digit being weighted 1, the second 2 and so on. If the check digit is calculated as "10" it is converted to "X".

A prominent possible subclass is ISBN10CheckDigit).

Since:
1.10.0
See Also:
  • Method Details

    • getInstance

      public static CheckDigit getInstance()
      Gets the singleton instance of this validator.
      Returns:
      A singleton instance of the class.
    • 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 X.

      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
    • toInt

      protected int toInt(char character, int leftPos, int rightPos) throws CheckDigitException

      Convert a character at a specified position to an integer value.

      Character 'X' check digit converted to 10.

      Overrides:
      toInt in class ModulusCheckDigit
      Parameters:
      character - The character to convert.
      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 integer value of the character.
      Throws:
      CheckDigitException - if an error occurs.