Class IBANCheckDigit
java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.IsoIec7064PureSystem
org.apache.commons.validator.routines.checkdigit.Modulus97CheckDigit
org.apache.commons.validator.routines.checkdigit.IBANCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit,IsoIecConstants
IBAN (International Bank Account Number) Check Digit calculation/validation.
This routine is based on the ISO 7064 Mod 97,10 check digit calculation routine.
The two check digit characters in a IBAN number are the third and fourth characters
in the code. For check digit calculation/validation the first four characters are moved
to the end of the code.
So CCDDnnnnnnn becomes nnnnnnnCCDD (where
CC is the country code and DD is the check digit). For
check digit calculation the check digit value should be set to zero (i.e.
CC00nnnnnnn in this example.
Note: the class does not check the format of the IBAN number, only the check digits.
For further information see Wikipedia - IBAN number.
- Since:
- 1.4
- 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalculate the Check Digit for an IBAN code.static CheckDigitGets the singleton instance of this validator.booleanValidate the check digit of an IBAN code.Methods inherited from class org.apache.commons.validator.routines.checkdigit.Modulus97CheckDigit
calculateModulus, getCharacterSet, getRadix, toIntMethods 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
-
Constructor Details
-
IBANCheckDigit
public IBANCheckDigit()
-
-
Method Details
-
getInstance
Gets the singleton instance of this validator.- Returns:
- A singleton instance of the class.
-
calculate
Calculate the Check Digit for an IBAN code.Note: The check digit is the third and fourth characters and is set to the value "
00".- Specified by:
calculatein interfaceCheckDigit- Overrides:
calculatein classModulus97CheckDigit- Parameters:
code- The code to calculate the Check Digit for- Returns:
- The calculated Check Digit as 2 numeric decimal characters, e.g. "42"
- Throws:
CheckDigitException- if an error occurs calculating the check digit for the specified code
-
isValid
Validate the check digit of an IBAN code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classModulus97CheckDigit- Parameters:
code- The code to validate- Returns:
trueif the check digit is valid, otherwisefalse
-