Class Modulus11XCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
- Direct Known Subclasses:
ISBN10CheckDigit,ISSNCheckDigit,Mod11XISBN10CheckDigit,Modulus11FINCheckDigit
11-X Numbers are a numeric code except for the last (check) digit which can have a value of "X".
Check digit calculation is based on modulus 11 with digits being weighted based by their position, from right to left (the default) with the right most digit being weighted 1, the second 2 and so on. If the check digit is calculated as "10" it is converted to "X".
A prominent possible subclass is ISBN10CheckDigit).
- Since:
- 1.10.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CheckDigitGets the singleton instance of this validator.protected StringtoCheckDigit(int charValue) Convert an integer value to a check digit.protected inttoInt(char character, int leftPos, int rightPos) Convert a character at a specified position to an integer value.Methods inherited from class org.apache.commons.validator.routines.checkdigit.Modulus11iWeightCheckDigit
isValid, weightedValueMethods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
calculate, calculateModulus, getCheckdigitLength, getModulus, sumDigits
-
Method Details
-
getInstance
Gets the singleton instance of this validator.- Returns:
- A singleton instance of the class.
-
toCheckDigit
Convert an integer value to a check digit.Note: this implementation only handles single-digit numeric values For non-numeric characters, override this method to provide integer-->character conversion.
Override to handle charValue 10.
Override to handle charValue X.
- Overrides:
toCheckDigitin classModulus11iWeightCheckDigit- Parameters:
charValue- The integer value of the character- Returns:
- The converted character
- Throws:
CheckDigitException- if integer character value doesn't represent a numeric character
-
toInt
Convert a character at a specified position to an integer value.
Character 'X' check digit converted to 10.
- Overrides:
toIntin classModulusCheckDigit- Parameters:
character- The character to convert.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 integer value of the character.
- Throws:
CheckDigitException- if an error occurs.
-