Top Description Fields Constructors Methods
org.hibernate.validator.internal.constraintvalidators.hv

public abstract Class ModCheckBase

extends Object
Class Inheritance
Known Direct Subclasses
org.hibernate.validator.internal.constraintvalidators.hv.ModCheckValidator, org.hibernate.validator.internal.constraintvalidators.hv.pl.PESELValidator, org.hibernate.validator.internal.constraintvalidators.hv.pl.PolishNumberValidator, org.hibernate.validator.internal.constraintvalidators.hv.LuhnCheckValidator, org.hibernate.validator.internal.constraintvalidators.hv.Mod10CheckValidator, org.hibernate.validator.internal.constraintvalidators.hv.Mod11CheckValidator
Imports
java.lang.invoke.MethodHandles, java.util.ArrayList, .List, java.util.regex.Pattern, jakarta.validation.ConstraintValidatorContext, org.hibernate.validator.internal.util.logging.Log, .LoggerFactory

ModCheckBase contains all shared methods and options used by Mod Check Validators http://en.wikipedia.org/wiki/Check_digit
Authors
George Gastaldi, Hardy Ferentschik, Victor Rezende dos Santos

Field Summary

Modifier and TypeField and Description
private int
checkDigitIndex

The index of the checksum digit

private static final int
private int
endIndex

The end index for the checksum calculation

private boolean
private static final Log
private static final Pattern
private int
startIndex

The start index for the checksum calculation

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private char
protected int

Returns:

the numeric int value represented by the character.
extractDigit
(char
the input char to be parsed
value
)

Returns the numeric int value of a char

private List<Integer>

Returns:

List of Integer objects.
extractDigits
(final String
the input string to be parsed
value
)

Parses the String value as a List of Integer objects

private String
protected void
initialize(int startIndex, int endIndex, int checkDigitIndex, boolean ignoreNonDigitCharacters)

public abstract boolean
isCheckDigitValid(List<Integer> digits, char checkDigit)

public boolean
isValid(final CharSequence value, final ConstraintValidatorContext context)

private String
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkDigitIndexback to summary
private int checkDigitIndex

The index of the checksum digit

DEC_RADIXback to summary
private static final int DEC_RADIX
endIndexback to summary
private int endIndex

The end index for the checksum calculation

ignoreNonDigitCharactersback to summary
private boolean ignoreNonDigitCharacters
LOGback to summary
private static final Log LOG
NUMBERS_ONLY_REGEXPback to summary
private static final Pattern NUMBERS_ONLY_REGEXP
startIndexback to summary
private int startIndex

The start index for the checksum calculation

Constructor Detail

ModCheckBaseback to summary
public ModCheckBase()

Method Detail

extractCheckDigitback to summary
private char extractCheckDigit(String value) throws IndexOutOfBoundsException
extractDigitback to summary
protected int extractDigit(char value) throws NumberFormatException

Returns the numeric int value of a char

Parameters
value:char

the input char to be parsed

Returns:int

the numeric int value represented by the character.

Exceptions
NumberFormatException:
in case character is not a digit
extractDigitsback to summary
private List<Integer> extractDigits(final String value) throws NumberFormatException

Parses the String value as a List of Integer objects

Parameters
value:String

the input string to be parsed

Returns:List<Integer>

List of Integer objects.

Exceptions
NumberFormatException:
in case any of the characters is not a digit
extractVerificationStringback to summary
private String extractVerificationString(String value) throws IndexOutOfBoundsException
initializeback to summary
protected void initialize(int startIndex, int endIndex, int checkDigitIndex, boolean ignoreNonDigitCharacters)
isCheckDigitValidback to summary
public abstract boolean isCheckDigitValid(List<Integer> digits, char checkDigit)
isValidback to summary
public boolean isValid(final CharSequence value, final ConstraintValidatorContext context)
stripNonDigitsIfRequiredback to summary
private String stripNonDigitsIfRequired(String value)
validateOptionsback to summary
private boolean validateOptions()