Class NHSCheckDigit

Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
com.cobber.fta.plugins.identity.NHSCheckDigit
All Implemented Interfaces:
Serializable, org.apache.commons.validator.routines.checkdigit.CheckDigit

public final class NHSCheckDigit extends org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
NHS Check Digit calculation/validation. This implementation validates/calculates NHS check digits.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an NHS Identifier Check Digit routine.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    calculateModulus(String code, boolean includesCheckDigit)
    Calculate the modulus for an NHS code.
    protected int
    weightedValue(int charValue, int leftPos, int rightPos)
    Calculates the weighted value of a character in the code at a specified position.

    Methods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit

    calculate, getModulus, isValid, sumDigits, toCheckDigit, toInt

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NHSCheckDigit

      public NHSCheckDigit()
      Construct an NHS Identifier Check Digit routine.
  • Method Details

    • calculateModulus

      protected int calculateModulus(String code, boolean includesCheckDigit) throws org.apache.commons.validator.routines.checkdigit.CheckDigitException
      Calculate the modulus for an NHS code.
      Overrides:
      calculateModulus in class org.apache.commons.validator.routines.checkdigit.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:
      org.apache.commons.validator.routines.checkdigit.CheckDigitException - if an error occurs calculating the modulus for the specified code
    • weightedValue

      protected int weightedValue(int charValue, int leftPos, int rightPos)

      Calculates the weighted value of a character in the code at a specified position.

      For NHS digits are weighted starting with 10 at the left-most digit and descending by one for each position.

      Specified by:
      weightedValue in class org.apache.commons.validator.routines.checkdigit.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 position of the character in the code, counting from right to left
      Returns:
      The weighted value of the character.