Package org.apache.commons.validator.routines.checkdigit

# Class ISSNCheckDigit

java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.ISSNCheckDigit

All Implemented Interfaces:
  `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 final CheckDigit`
  `ISSN_CHECK_DIGIT`
  Singleton ISSN Check Digit instance

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ISSNCheckDigit()`
  Creates the instance using a checkdigit modulus of 11.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected String`
  `toCheckDigit(int charValue)`
  Convert an integer value to a check digit.
  `protected int`
  `toInt(char character, int leftPos, int rightPos)`
  Convert a character at a specified position to an integer value.
  `protected int`
  `weightedValue(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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ISSN_CHECK_DIGIT

    public static final CheckDigit ISSN_CHECK_DIGIT
    Singleton ISSN Check Digit instance

- ## Constructor Details

  - ### ISSNCheckDigit

    public ISSNCheckDigit()
    Creates the instance using a checkdigit modulus of 11.

- ## Method Details

  - ### toCheckDigit

    protected String toCheckDigit(int charValue) throws CheckDigitException
    Description copied from class: `ModulusCheckDigit`
    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.

    Overrides:
      `toCheckDigit` in class `ModulusCheckDigit`
    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 CheckDigitException
    Description copied from class: `ModulusCheckDigit`
    Convert 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:
      `toInt` in class `ModulusCheckDigit`
    Parameters:
      `character` - The character to convert
      `leftPos` - 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

  - ### weightedValue

    protected int weightedValue(int charValue, int leftPos, int rightPos) throws CheckDigitException
    Description copied from class: `ModulusCheckDigit`
    Calculates 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:
      `weightedValue` in class `ModulusCheckDigit`
    Parameters:
      `charValue` - The numeric value of the character
      `leftPos` - The position of the character in the code, counting from left to right
      `rightPos` - 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