Class Modulus97CheckDigit
java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.IsoIec7064PureSystem
org.apache.commons.validator.routines.checkdigit.Modulus97CheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit,IsoIecConstants
- Direct Known Subclasses:
IBANCheckDigit
MOD 97-10 module similar to ISO/IEC 7064, MOD 97-10.
In difference to the standard this module applies to alphanumeric Strings.
Check digits can be from 02 to 98 (00 and 01 are not possible)
See Wikipedia - ISO/IEC_7064 (de) for more details on ISO/IEC 7064, MOD 97-10
This MOD 97-10 module can be used to validate the LEI (Legal Entity Identifier), ICD id 0199
- Since:
- 1.10.0
- See Also:
-
Field Summary
Fields inherited from interface org.apache.commons.validator.routines.checkdigit.IsoIecConstants
ALPHABETIC, ALPHANUMERIC, ALPHANUMERIC_PLUS_STAR, MODULUS_1271, MODULUS_37, MODULUS_661, MODULUS_97, NUMERIC, NUMERIC_PLUS_X, RADIX_10, RADIX_2, RADIX_26, RADIX_36 -
Method Summary
Modifier and TypeMethodDescriptionCalculate a modulus Check Digit for a code which does not yet have one.protected intcalculateModulus(String code, boolean includesCheckDigit) Calculate the modulus for a code.protected StringMOD 11-2 check characters are “0” to “9” plus “X” for example.static CheckDigitGets the singleton instance of this validator.protected intgetRadix()Radix is the second number following “MOD” in the ISO/IEC designation, f.i. 2 for "MOD 11-2"booleanValidate a modulus check digit for a code.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.IsoIec7064PureSystem
getCheckdigitLength, toCheckDigit, weightedValueMethods inherited from class org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
getModulus, sumDigits
-
Method Details
-
getInstance
Gets the singleton instance of this validator.- Returns:
- A singleton instance of the class.
-
getRadix
protected int getRadix()Description copied from class:IsoIec7064PureSystemRadix is the second number following “MOD” in the ISO/IEC designation, f.i. 2 for "MOD 11-2"- Specified by:
getRadixin classIsoIec7064PureSystem- Returns:
- the radix of the Check Digit routine
-
getCharacterSet
Description copied from class:IsoIec7064PureSystemMOD 11-2 check characters are “0” to “9” plus “X” for example.- Specified by:
getCharacterSetin classIsoIec7064PureSystem- Returns:
- a String containing characters the check digit is build from.
This can be
IsoIecConstants.NUMERIC,IsoIecConstants.ALPHABETIC,IsoIecConstants.ALPHANUMERIC,IsoIecConstants.NUMERIC_PLUS_X,IsoIecConstants.ALPHANUMERIC_PLUS_STAR
-
calculate
Description copied from class:ModulusCheckDigitCalculate a modulus Check Digit for a code which does not yet have one.- Specified by:
calculatein interfaceCheckDigit- Overrides:
calculatein classIsoIec7064PureSystem- Parameters:
code- The code for which to calculate the Check Digit; the check digit should not be included- Returns:
- The calculated Check Digit
- Throws:
CheckDigitException- if an error occurs calculating the check digit
-
calculateModulus
Description copied from class:ModulusCheckDigitCalculate the modulus for a code.- Overrides:
calculateModulusin classIsoIec7064PureSystem- Parameters:
code- The code to calculate the modulus for.includesCheckDigit- Whether the code includes the Check Digit or not.- Returns:
- The modulus value
- Throws:
CheckDigitException- if an error occurs calculating the modulus for the specified code
-
isValid
Description copied from class:ModulusCheckDigitValidate a modulus check digit for a code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classIsoIec7064PureSystem- Parameters:
code- The code to validate- Returns:
trueif the check digit is valid, otherwisefalse
-
toInt
Description copied from class:IsoIec7064PureSystemConvert a character at a specified position to an integer value.Note: this implementation only handlers numeric values For non-numeric characters, override this method to provide character-->integer conversion.
Overrides to handle numeric, alphabetic or alphanumeric values respectively.
- Overrides:
toIntin classIsoIec7064PureSystem- Parameters:
character- The character to convertleftPos- The position of the character in the code, counting from left to right (for identifiying the position in the string)rightPos- The position of the character in the code, counting from right to left (not used here)- Returns:
- The integer value of the character
- Throws:
CheckDigitException- if character is non-numeric
-