Class Modulus31CheckDigit

All Implemented Interfaces:
Serializable, CheckDigit, IsoIecConstants

public class Modulus31CheckDigit extends IsoIec7064PureSystem implements IsoIecConstants
Implements Moduli-31 check digit calculation/validation.

Moduli-31 applies to finish TIN (HETU) number, the check digit has one alphanumeric char. See Wikipedia 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 validator.
      Returns:
      A singleton instance of the class.
    • getRadix

      protected int getRadix()
      Radix is the second number following “MOD” in the ISO/IEC designation, f.i. 2 for "MOD 11-2"

      Overridden because not used for moduli-31 calculation

      Specified by:
      getRadix in class IsoIec7064PureSystem
      Returns:
      the radix of the Check Digit routine
    • getCharacterSet

      protected String getCharacterSet()
      Check characters are “0” to “9” plus 21 ALPHABETIC chars.
      Specified by:
      getCharacterSet in class IsoIec7064PureSystem
      Returns:
      a String containing characters the check digit is build from. This is IsoIecConstants.ALPHANUMERIC31
    • calculate

      public String calculate(String code) throws CheckDigitException
      Description copied from class: ModulusCheckDigit
      Calculate a modulus Check Digit for a code which does not yet have one.
      Specified by:
      calculate in interface CheckDigit
      Overrides:
      calculate in class IsoIec7064PureSystem
      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
    • isValid

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