Class Modulus11XiLeftCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
Digits are weighted based by their position, from left to right with the first digit being weighted 1, the second 2 and so on. Check digit can have a value of "X" (10).
This module is used to calculate EC index numbers.
EC Index Numbers are a numeric code except for the last (check) digit
which can have a value of "X".
Note that these module do not validate the input for syntax.
Such validation is performed by the ECIndexNumberValidator
- Since:
- 1.9.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 intweightedValue(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.Modulus11iBSNCheckDigit
calculateMethods inherited from class org.apache.commons.validator.routines.checkdigit.Modulus11iWeightCheckDigit
isValidMethods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
calculateModulus, getCheckdigitLength, getModulus, sumDigits, toInt
-
Method Details
-
getInstance
Gets the singleton instance of this validator.- Returns:
- A singleton instance of the class.
-
weightedValue
Calculates the weighted value of a character in the code at a specified position.Some modulus routines weight the value of a character depending on its position in the code (e.g. ISBN-10), while others use different weighting factors for odd/even positions (e.g. EAN or Luhn). Implement the appropriate mechanism required by overriding this method.
Implement to handle weights as right position.
Override to handle weights 1 2 3 4 5 6 7 8 9, then 1 2 3 ... as left position.
Override to handle weights as left position.
- Overrides:
weightedValuein classModulus11iLeftCheckDigit- Parameters:
charValue- The numeric value of the characterleftPos- 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
- Throws:
CheckDigitException- if an error occurs calculating the weighted value
-
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 10 as invalid check digit value.
Override to handle charValue X.
- Overrides:
toCheckDigitin classModulus11iLeftCheckDigit- Parameters:
charValue- The integer value of the character- Returns:
- The converted character
- Throws:
CheckDigitException- if integer character value doesn't represent a numeric character
-