Class VATidNLCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
BTW-identificatienummer. Note: since 2020 there are two validation methods. MOD 11 with G(i) = i : the last three characters (B + 2-digit company index) are not part of the check digit calculation. MOD 97 used additionally : 'NL'+(nine digits)+B+2checkdigits is used for validation.
See Wikipedia - VAT IN for more details.
- Since:
- 1.10.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCalculate a modulus Check Digit for a code which does not yet have one.static CheckDigitGets the singleton instance of this validator.booleanValidate a modulus check digit for a code.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.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.
- Overrides:
weightedValuein classModulus11iWeightCheckDigit- 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
-
calculate
Calculate a modulus Check Digit for a code which does not yet have one.- Specified by:
calculatein interfaceCheckDigit- Overrides:
calculatein classModulus11iBSNCheckDigit- 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
-
isValid
Validate a modulus check digit for a code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classModulus11iWeightCheckDigit- Parameters:
ocode- The code to validate- Returns:
trueif the check digit is valid, otherwisefalse
-
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 because charValue 10 is an invalid check digit value.
- 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
-