|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.validator.routines.ISBNValidator
public class ISBNValidator
ISBN-10 and ISBN-13 Code Validation.
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:
| Field Summary | |
|---|---|
private boolean |
convert
|
private static java.lang.String |
GROUP
|
private static ISBNValidator |
ISBN_VALIDATOR
ISBN Code Validator (which converts ISBN-10 codes to ISBN-13 |
private static ISBNValidator |
ISBN_VALIDATOR_NO_CONVERT
ISBN Code Validator (which converts ISBN-10 codes to ISBN-13 |
(package private) static java.lang.String |
ISBN10_REGEX
ISBN-10 consists of 4 groups of numbers separated by either dashes (-) or spaces. |
private CodeValidator |
isbn10Validator
ISBN-10 Code Validator |
(package private) static java.lang.String |
ISBN13_REGEX
ISBN-13 consists of 5 groups of numbers separated by either dashes (-) or spaces. |
private CodeValidator |
isbn13Validator
ISBN-13 Code Validator |
private static java.lang.String |
PUBLISHER
|
private static java.lang.String |
SEP
|
private static java.lang.String |
TITLE
|
| Constructor Summary | |
|---|---|
ISBNValidator()
Construct 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 | |
|---|---|
java.lang.String |
convertToISBN13(java.lang.String isbn10)
Convert an ISBN-10 code to an ISBN-13 code. |
static ISBNValidator |
getInstance()
Return a singleton instance of the ISBN validator which converts ISBN-10 codes to ISBN-13. |
static ISBNValidator |
getInstance(boolean convert)
Return a singleton instance of the ISBN validator specifying whether ISBN-10 codes should be converted to ISBN-13. |
boolean |
isValid(java.lang.String code)
Check the code is either a valid ISBN-10 or ISBN-13 code. |
boolean |
isValidISBN10(java.lang.String code)
Check the code is a valid ISBN-10 code. |
boolean |
isValidISBN13(java.lang.String code)
Check the code is a valid ISBN-13 code. |
java.lang.String |
validate(java.lang.String code)
Check the code is either a valid ISBN-10 or ISBN-13 code. |
java.lang.String |
validateISBN10(java.lang.String code)
Check the code is a valid ISBN-10 code. |
java.lang.String |
validateISBN13(java.lang.String code)
Check the code is a valid ISBN-13 code. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String SEP
private static final java.lang.String GROUP
private static final java.lang.String PUBLISHER
private static final java.lang.String TITLE
static final java.lang.String ISBN10_REGEX
static final java.lang.String ISBN13_REGEX
private static final ISBNValidator ISBN_VALIDATOR
private static final ISBNValidator ISBN_VALIDATOR_NO_CONVERT
private CodeValidator isbn10Validator
private CodeValidator isbn13Validator
private final boolean convert
| Constructor Detail |
|---|
public ISBNValidator()
public ISBNValidator(boolean convert)
convert - true if valid ISBN-10 codes
should be converted to ISBN-13 codes or false
if valid ISBN-10 codes should be returned unchanged.| Method Detail |
|---|
public static ISBNValidator getInstance()
public static ISBNValidator getInstance(boolean convert)
convert - true if valid ISBN-10 codes
should be converted to ISBN-13 codes or false
if valid ISBN-10 codes should be returned unchanged.
public boolean isValid(java.lang.String code)
code - The code to validate.
true if a valid ISBN-10 or
ISBN-13 code, otherwise false.public boolean isValidISBN10(java.lang.String code)
code - The code to validate.
true if a valid ISBN-10
code, otherwise false.public boolean isValidISBN13(java.lang.String code)
code - The code to validate.
true if a valid ISBN-13
code, otherwise false.public java.lang.String validate(java.lang.String 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
convertToISBN13 is true.
code - The code to validate.
null.public java.lang.String validateISBN10(java.lang.String code)
If valid, this method returns the ISBN-10 code with formatting characters removed (i.e. space or hyphen).
code - The code to validate.
null.public java.lang.String validateISBN13(java.lang.String code)
If valid, this method returns the ISBN-13 code with formatting characters removed (i.e. space or hyphen).
code - The code to validate.
null.public java.lang.String convertToISBN13(java.lang.String isbn10)
This method requires a valid ISBN-10 with NO formatting characters.
isbn10 - The ISBN-10 code to convert
null
if the ISBN-10 code is not valid
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||