Package com.cobber.fta.plugins.identity
Class NHSCheckDigit
- Object
-
- org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
-
- com.cobber.fta.plugins.identity.NHSCheckDigit
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NHSCheckDigit()
Construct an NHS Identifier Check Digit routine.
-
Method Summary
All Methods Instance Methods Concrete Methods 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.
-
-
-
Method Detail
-
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 classorg.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 classorg.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 rightrightPos
- The position of the character in the code, counting from right to left- Returns:
- The weighted value of the character.
-
-