001package org.xbib.standardnumber.check; 002 003public interface Digit { 004 005 /** 006 * Add check digits to a string containing digits 007 * @param digits the input data string containing only digits '0'-'9' 008 * @return a new string containing data and check digits 009 */ 010 String encode(String digits); 011 012 /** 013 * Verify a string that has been encoded with a check digit 014 * 015 * @param digits input digits 016 * @return true if valid, false otherwise 017 */ 018 boolean verify(String digits); 019 020 /** 021 * Computes the check digit value 022 * 023 * @param digits - a string containing data 024 * @return an integer representing the check digit 025 */ 026 int compute(String digits); 027 028 /** 029 * Extract just the check digit from an encoded string 030 * 031 * @param digits input data containing check and data digits 032 * @return the check digit, as an int 033 */ 034 int getDigit(String digits); 035 036 /** 037 * Extracts the raw data without the check digits 038 * 039 * @param digits -- A string containing only digits 0-9 040 * @return a string without check digits 041 */ 042 String getNumber(String digits); 043}