org.apache.commons.validator.routines.checkdigit.CheckDigit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isoiec7064 Show documentation
Show all versions of isoiec7064 Show documentation
A Java library to calculate and validate ISO/IEC 7064 System check digits.
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.validator.routines.checkdigit;
/**
* Check Digit calculation and validation.
*
* The logic for validating check digits has previously been
* embedded within the logic for specific code validation, which
* includes other validations such as verifying the format
* or length of a code. {@link CheckDigit} provides for separating out
* the check digit calculation logic enabling it to be more easily
* tested and reused.
*
*
* Although Commons Validator is primarily concerned with validation,
* {@link CheckDigit} also defines behavior for calculating/generating check
* digits, since it makes sense that users will want to (re-)use the
* same logic for both.
*
*
* Implementations
* See the
* Package Summary for a full
* list of implementations provided within Commons Validator.
*
* @see org.apache.commons.validator.routines.CodeValidator
* @since 1.4
*/
public interface CheckDigit {
/**
* Calculates the Check Digit for a code.
*
* @param code The code to calculate the Check Digit for.
* The string must not include the check digit
* @return The calculated Check Digit
* @throws CheckDigitException if an error occurs.
*/
String calculate(String code) throws CheckDigitException;
/**
* Validates the check digit for the code.
*
* @param code The code to validate, the string must include the check digit.
* @return {@code true} if the check digit is valid, otherwise
* {@code false}.
*/
boolean isValid(String code);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy