Class VATidROCheckDigit
java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.VATidROCheckDigit
- All Implemented Interfaces:
Serializable,CheckDigit
Romanian VAT identification number (VATIN) Check Digit calculation/validation.
cod de înregistrare în scopuri de TVA (TVA), sometimes called Codul de identificare fiscală (CIF)
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.protected intcalculateModulus(String code, boolean includesCheckDigit) Calculate the modulus for a code.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
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.For VATID digits are weighted by their position from left to right.
- Specified by:
weightedValuein classModulusCheckDigit- Parameters:
charValue- The numeric value of the character.leftPos- The position of the character in the code, counting from left to rightrightPos- The positionof 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 classModulusCheckDigit- 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
Calculate the modulus for a code.Override to multiply the total by 10.
- Overrides:
calculateModulusin classModulusCheckDigit- 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
Validate a modulus check digit for a code.- Specified by:
isValidin interfaceCheckDigit- Overrides:
isValidin classModulusCheckDigit- Parameters:
code- 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.
- Overrides:
toCheckDigitin classModulusCheckDigit- Parameters:
charValue- The integer value of the character- Returns:
- The converted character
- Throws:
CheckDigitException- if integer character value doesn't represent a numeric character
-