Class CheckDigit

java.lang.Object
org.emau.icmvc.ganimed.ttp.psn.generator.CheckDigits
org.emau.icmvc.ganimed.ttp.psn.generator.CheckDigit
All Implemented Interfaces:
Serializable

public abstract class CheckDigit extends CheckDigits
Extends CheckDigits to be a common base for all algorithms handling a single check digit
See Also:
  • Constructor Details

    • CheckDigit

      protected CheckDigit()
    • CheckDigit

      protected CheckDigit(Alphabet alphabet)
  • Method Details

    • generateCheckDigits

      public String generateCheckDigits(String message) throws CharNotInAlphabetException
      Specified by:
      generateCheckDigits in class CheckDigits
      Parameters:
      message - string for which check digits should be generated
      Returns:
      check digits
      Throws:
      CharNotInAlphabetException - if the message contains characters which are not contained in the alphabet
    • check

      public void check(String value, int messageLength) throws CharNotInAlphabetException, InvalidPSNException
      Specified by:
      check in class CheckDigits
      Parameters:
      value - string (including check digits) to be checked
      messageLength - length of [value] without check digits
      Throws:
      CharNotInAlphabetException - if the value contains characters which are not contained in the alphabet
      InvalidPSNException - if the value is not a valid pseudonym
    • getNumberOfCheckDigits

      public int getNumberOfCheckDigits(int messageLength)
      Description copied from class: CheckDigits
      Returns the number of check digits computed by this algorithm for a message with a given length.
      Specified by:
      getNumberOfCheckDigits in class CheckDigits
      Parameters:
      messageLength - the length of the message
      Returns:
      the number of check digits computed by this algorithm for a message with a given length
    • getEffectiveMaxMessageLength

      public int getEffectiveMaxMessageLength(int total)
      Description copied from class: CheckDigits
      Returns the maximum length of messages for which the resulting value including check digits is not longer than the given total.
      Overrides:
      getEffectiveMaxMessageLength in class CheckDigits
      Returns:
      the maximum length of messages for which the resulting value including check digits is not longer than the given total
    • calculateCheckDigit

      protected abstract char calculateCheckDigit(String message) throws CharNotInAlphabetException
      Throws:
      CharNotInAlphabetException