Class ISSNCheckDigit
- java.lang.Object
-
- org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
-
- org.apache.commons.validator.routines.checkdigit.ISSNCheckDigit
-
- All Implemented Interfaces:
java.io.Serializable,CheckDigit
public final class ISSNCheckDigit extends ModulusCheckDigit
International Standard Serial Number (ISSN) is an eight-digit serial number used to uniquely identify a serial publication.The format is: ISSN dddd-dddC where: d = decimal digit (0-9) C = checksum (0-9 or X) The checksum is formed by adding the first 7 digits multiplied by the position in the entire number (counting from the right). For example, abcd-efg would be 8a + 7b + 6c + 5d + 4e +3f +2g. The check digit is modulus 11, where the value 10 is represented by 'X' For example: ISSN 0317-8471 ISSN 1050-124X
Note: This class expects the input to be numeric only, with all formatting removed. For example:
03178471 1050124X
- Since:
- 1.5.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static CheckDigitISSN_CHECK_DIGITSingleton ISSN Check Digit instanceprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description ISSNCheckDigit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringtoCheckDigit(int charValue)Convert an integer value to a check digit.protected inttoInt(char character, int leftPos, int rightPos)Convert a character at a specified position to an integer value.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
calculate, calculateModulus, getModulus, isValid, sumDigits
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ISSN_CHECK_DIGIT
public static final CheckDigit ISSN_CHECK_DIGIT
Singleton ISSN Check Digit instance
-
-
Method Detail
-
weightedValue
protected int weightedValue(int charValue, int leftPos, int rightPos) throws CheckDigitExceptionDescription copied from class:ModulusCheckDigitCalculates 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.
- Specified by:
weightedValuein classModulusCheckDigit- Parameters:
charValue- The numeric value of the characterleftPos- 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
-
toCheckDigit
protected java.lang.String toCheckDigit(int charValue) throws CheckDigitExceptionDescription copied from class:ModulusCheckDigitConvert 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.
- 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
-
toInt
protected int toInt(char character, int leftPos, int rightPos) throws CheckDigitExceptionDescription copied from class:ModulusCheckDigitConvert a character at a specified position to an integer value.Note: this implementation only handlers numeric values For non-numeric characters, override this method to provide character-->integer conversion.
- Overrides:
toIntin classModulusCheckDigit- Parameters:
character- The character to convertleftPos- The position of the character in the code, counting from left to right (for identifiying the position in the string)rightPos- The position of the character in the code, counting from right to left (not used here)- Returns:
- The integer value of the character
- Throws:
CheckDigitException- if character is non-numeric
-
-