Class Modulus11TenCheckDigit

java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.Modulus11TenCheckDigit
All Implemented Interfaces:
Serializable, CheckDigit

public class Modulus11TenCheckDigit extends ModulusCheckDigit
MOD 11,10 module according to ISO/IEC 7064.

See Wikipedia - ISO/IEC_7064 (de) for more details.

This MOD 11,10 module can also be used to validate TIN_DE, TIN_HR, the VATIN_DE and VATIN_HR used in VATINCheckDigit

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.
    • weightedValue

      protected int weightedValue(int charValue, int leftPos, int rightPos)
      Calculates the weighted value of a character in the code at a specified position.

      In MOD 11,10 algorithm there is no weight, so the weighted value is equal to the character value.

      Specified by:
      weightedValue in class ModulusCheckDigit
      Parameters:
      charValue - The numeric value of the character.
      leftPos - The position of the character in the code, counting from left to right
      rightPos - The positionof the character in the code, counting from right to left
      Returns:
      The weighted value equals to charValue.
    • calculate

      public String calculate(String code) throws CheckDigitException
      Calculate a modulus Check Digit for a code which does not yet have one.
      Specified by:
      calculate in interface CheckDigit
      Overrides:
      calculate in class ModulusCheckDigit
      Parameters:
      code - The code for which to calculate the Check Digit; the check digit should not be included
      Returns:
      The calculated Check Digit
      Throws:
      CheckDigitException - if an error occurs calculating the check digit
    • calculateModulus

      protected int calculateModulus(String code, boolean includesCheckDigit) throws CheckDigitException
      Calculate the modulus for a code.
      Overrides:
      calculateModulus in class ModulusCheckDigit
      Parameters:
      code - The code to calculate the modulus for.
      includesCheckDigit - Whether the code includes the Check Digit or not.
      Returns:
      The modulus value
      Throws:
      CheckDigitException - if an error occurs calculating the modulus for the specified code
    • isValid

      public boolean isValid(String code)
      Validate a modulus check digit for a code.
      Specified by:
      isValid in interface CheckDigit
      Overrides:
      isValid in class ModulusCheckDigit
      Parameters:
      code - The code to validate
      Returns:
      true if the check digit is valid, otherwise false