Modifier and Type | Field and Description |
---|---|
private static String |
CHECK |
private static String |
GROUP |
private static String |
ISBN_PATTERN
ISBN consists of 4 groups of numbers separated by either dashes (-)
or spaces.
|
private static String |
PUBLISHER |
private static String |
SEP |
private static String |
TITLE |
Constructor and Description |
---|
ISBNValidator()
Default Constructor.
|
Modifier and Type | Method and Description |
---|---|
private String |
clean(String isbn)
Removes all non-digit characters except for 'X' which is a valid ISBN
character.
|
private boolean |
isFormatted(String isbn)
Returns true if the ISBN contains one of the separator characters space
or dash.
|
boolean |
isValid(String isbn)
If the ISBN is formatted with space or dash separators its format is
validated.
|
private boolean |
isValidPattern(String isbn)
Returns true if the ISBN is formatted properly.
|
private int |
sum(String isbn)
Returns the sum of the weighted ISBN characters.
|
private int |
toInt(char ch)
Returns the numeric value represented by the character.
|
private static final String SEP
private static final String GROUP
private static final String PUBLISHER
private static final String TITLE
private static final String CHECK
private static final String ISBN_PATTERN
public boolean isValid(String isbn)
isbn
- Candidate ISBN number to be validated. null
is
considered invalid.private int sum(String isbn)
private String clean(String isbn)
private int toInt(char ch)
private boolean isFormatted(String isbn)
private boolean isValidPattern(String isbn)
Copyright (c) 2001-2004 Apache Software Foundation