Class ISBNValidator
- All Implemented Interfaces:
Serializable
This validator validates the code is either a valid ISBN-10
(using a CodeValidator with the ISBN10CheckDigit)
or a valid ISBN-13 code (using a CodeValidator with the
the EAN13CheckDigit routine).
The validate() methods return the ISBN code with formatting
characters removed if valid or null if invalid.
This validator also provides the facility to convert ISBN-10 codes to
ISBN-13 if the convert property is true.
From 1st January 2007 the book industry will start to use a new 13 digit ISBN number (rather than this 10 digit ISBN number). ISBN-13 codes are EAN codes, for more information see:
- Since:
- Validator 1.4
- Version:
- $Revision: 1649191 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate static final Stringprivate static final ISBNValidatorISBN Code Validator (which converts ISBN-10 codes to ISBN-13private static final ISBNValidatorISBN Code Validator (which converts ISBN-10 codes to ISBN-13(package private) static final StringISBN-10 consists of 4 groups of numbers separated by either dashes (-) or spaces.private final CodeValidatorISBN-10 Code Validator(package private) static final StringISBN-13 consists of 5 groups of numbers separated by either dashes (-) or spaces.private final CodeValidatorISBN-13 Code Validatorprivate static final Stringprivate static final Stringprivate static final longprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an ISBN validator which converts ISBN-10 codes to ISBN-13.ISBNValidator(boolean convert) Construct an ISBN validator indicating whether ISBN-10 codes should be converted to ISBN-13. -
Method Summary
Modifier and TypeMethodDescriptionconvertToISBN13(String isbn10) Convert an ISBN-10 code to an ISBN-13 code.static ISBNValidatorReturn a singleton instance of the ISBN validator which converts ISBN-10 codes to ISBN-13.static ISBNValidatorgetInstance(boolean convert) Return a singleton instance of the ISBN validator specifying whether ISBN-10 codes should be converted to ISBN-13.booleanCheck the code is either a valid ISBN-10 or ISBN-13 code.booleanisValidISBN10(String code) Check the code is a valid ISBN-10 code.booleanisValidISBN13(String code) Check the code is a valid ISBN-13 code.Check the code is either a valid ISBN-10 or ISBN-13 code.validateISBN10(String code) Check the code is a valid ISBN-10 code.validateISBN13(String code) Check the code is a valid ISBN-13 code.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
SEP
- See Also:
-
GROUP
- See Also:
-
PUBLISHER
- See Also:
-
TITLE
- See Also:
-
ISBN10_REGEX
ISBN-10 consists of 4 groups of numbers separated by either dashes (-) or spaces. The first group is 1-5 characters, second 1-7, third 1-6, and fourth is 1 digit or an X.- See Also:
-
ISBN13_REGEX
ISBN-13 consists of 5 groups of numbers separated by either dashes (-) or spaces. The first group is 978 or 979, the second group is 1-5 characters, third 1-7, fourth 1-6, and fifth is 1 digit.- See Also:
-
ISBN_VALIDATOR
ISBN Code Validator (which converts ISBN-10 codes to ISBN-13 -
ISBN_VALIDATOR_NO_CONVERT
ISBN Code Validator (which converts ISBN-10 codes to ISBN-13 -
isbn10Validator
ISBN-10 Code Validator -
isbn13Validator
ISBN-13 Code Validator -
convert
private final boolean convert
-
-
Constructor Details
-
ISBNValidator
public ISBNValidator()Construct an ISBN validator which converts ISBN-10 codes to ISBN-13. -
ISBNValidator
public ISBNValidator(boolean convert) Construct an ISBN validator indicating whether ISBN-10 codes should be converted to ISBN-13.- Parameters:
convert-trueif valid ISBN-10 codes should be converted to ISBN-13 codes orfalseif valid ISBN-10 codes should be returned unchanged.
-
-
Method Details
-
getInstance
Return a singleton instance of the ISBN validator which converts ISBN-10 codes to ISBN-13.- Returns:
- A singleton instance of the ISBN validator.
-
getInstance
Return a singleton instance of the ISBN validator specifying whether ISBN-10 codes should be converted to ISBN-13.- Parameters:
convert-trueif valid ISBN-10 codes should be converted to ISBN-13 codes orfalseif valid ISBN-10 codes should be returned unchanged.- Returns:
- A singleton instance of the ISBN validator.
-
isValid
Check the code is either a valid ISBN-10 or ISBN-13 code.- Parameters:
code- The code to validate.- Returns:
trueif a valid ISBN-10 or ISBN-13 code, otherwisefalse.
-
isValidISBN10
Check the code is a valid ISBN-10 code.- Parameters:
code- The code to validate.- Returns:
trueif a valid ISBN-10 code, otherwisefalse.
-
isValidISBN13
Check the code is a valid ISBN-13 code.- Parameters:
code- The code to validate.- Returns:
trueif a valid ISBN-13 code, otherwisefalse.
-
validate
Check the code is either a valid ISBN-10 or ISBN-13 code.If valid, this method returns the ISBN code with formatting characters removed (i.e. space or hyphen).
Converts an ISBN-10 codes to ISBN-13 if
convertToISBN13istrue.- Parameters:
code- The code to validate.- Returns:
- A valid ISBN code if valid, otherwise
null.
-
validateISBN10
-
validateISBN13
-
convertToISBN13
-