Class ISSNValidator
java.lang.Object
org.apache.commons.validator.routines.ISSNValidator
- All Implemented Interfaces:
Serializable
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 This class strips off the 'ISSN ' prefix if it is present before passing the remainder to the checksum routine.
Note: the isValid(String) and invalid input: '{@link /*missing*/}' methods strip off any leading
or trailing spaces before doing the validation.
To ensure that only a valid code (without 'ISSN ' prefix) is passed to a method,
use the following code:
Object valid = validator.validate(input);
if (valid != null) {
some_method(valid.toString());
}
- Since:
- 1.5.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final ISSNValidatorISSN Code Validatorprivate static final CodeValidatorprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToEAN13(String issn, String suffix) Convert an ISSN code to an EAN-13 code.static ISSNValidatorReturn a singleton instance of the ISSN validatorbooleanCheck the code is a valid ISSN code after any transformation by the validate routine.Check the code is valid ISSN code.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ISSN_REGEX
- See Also:
-
issnValidator
-
ISSN_VALIDATOR
ISSN Code Validator
-
-
Constructor Details
-
ISSNValidator
public ISSNValidator()
-
-
Method Details
-
getInstance
Return a singleton instance of the ISSN validator- Returns:
- A singleton instance of the ISSN validator.
-
isValid
Check the code is a valid ISSN code after any transformation by the validate routine.- Parameters:
code- The code to validate.- Returns:
trueif a valid ISSN code, otherwisefalse.
-
validate
-
convertToEAN13
Convert an ISSN code to an EAN-13 code.This method requires a valid ISSN code. It may contain a leading 'ISSN ' prefix, as the input is passed through the
validate(String)method.- Parameters:
issn- The ISSN code to convertsuffix- the two digit suffix, e.g. "00"- Returns:
- A converted EAN-13 code or
nullif the input ISSN code is not valid
-