Class ISBN
java.lang.Object
de.creativecouple.validation.isbn.ISBN
- All Implemented Interfaces:
Serializable
,Comparable<ISBN>
Simple domain object, representing a single ISBN identifier.
It consists of five parts, conformant with the ISO 2108 standard:
It consists of five parts, conformant with the ISO 2108 standard:
- GS1/EAN/UCC prefix,
- agency/registration group code,
- publisher code,
- book title number,
- check digit.
Usage:
ISBN isbn1 = ISBN.valueOf("978-0557504695");
isbn1.toString(); // "978-0-557-50469-5"
ISBN isbn2 = ISBN.valueOf("0-557-50469-4");
isbn2.toString(); // "978-0-557-50469-5"
isbn1.equals(isbn2); // true
- Author:
- Peter Liske (CreativeCouple)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Two ISBN objects with the same ISBN-13 representation are treated equal.char
To meet the EAN criteria for valid article numbers, each ISBN has an additional digit to increase redundancy and to spot errors.getGroup()
There are group codes assigned with each local ISBN agency, e.g.The range definition from the Internation ISBN Agency associates a name with each local group.The group prefix is the substring that all valid ISBNs from that group start with.The EAN/UCC prefix represents the country/region in the EAN/GTIN standard.The range definition from the International ISBN Agency associates a name with each prefix.There are local ISBN agencies around the world who take care of assigning number ranges for publishers.The publisher prefix is the substring that all valid ISBNs from that publisher range start with.getTitle()
Each publication has a title identifier that is unique within the publisher's number range.int
hashCode()
Returns the compact ISBN-13 representation.Returns the human-readable ISO-2108 standard representation of this ISBN.toString()
Returns the correctly hyphened ISBN-13 representation.toURI()
Returns the URI for this ISBN.static void
Load the ISBN definition from the latest release at github.com.static ISBN
Parses a given string input and returns an ISBN object.
-
Method Details
-
getPrefix
The EAN/UCC prefix represents the country/region in the EAN/GTIN standard. Currently only "978" and "979" are associated with the International ISBN Agency.,–––⹁ 978-0-557-50469-5 `–––´
- Returns:
- the ISBN prefix, e.g. "978" or "979"
-
getPrefixName
The range definition from the International ISBN Agency associates a name with each prefix. So far this is always "International ISBN Agency".- Returns:
- the agency's name associated with the ISBN prefix
-
getGroup
There are group codes assigned with each local ISBN agency, e.g. for single countries or language regions. It is the second piece of the ISBN.,–⹁ 978-0-557-50469-5 `–´
- Returns:
- the group code of the ISBN, e.g. "0" or "610"
-
getGroupPrefix
The group prefix is the substring that all valid ISBNs from that group start with.,–––––⹁ 978-0-557-50469-5 `–––––´
- Returns:
- the group code of the ISBN, e.g. "978-0"
-
getGroupName
The range definition from the Internation ISBN Agency associates a name with each local group.- Returns:
- the agency's name associated with the group prefix, e.g. "English language" or "Turkey"
-
getPublisher
There are local ISBN agencies around the world who take care of assigning number ranges for publishers. This publisher code is the third piece of the ISBN.,–––⹁ 978-0-557-50469-5 `–––´
- Returns:
- the publisher code of the ISBN, e.g. "557"
-
getPublisherPrefix
The publisher prefix is the substring that all valid ISBNs from that publisher range start with.,–––––––––⹁ 978-0-557-50469-5 `–––––––––´
- Returns:
- the publisher's prefix of the ISBN, e.g. "978-0-557"
-
getTitle
Each publication has a title identifier that is unique within the publisher's number range. It is the fourth piece of the ISBN.,–––––⹁ 978-0-557-50469-5 `–––––´
- Returns:
- the title code of the ISBN, e.g. "50469"
-
getCheckdigit
public char getCheckdigit()To meet the EAN criteria for valid article numbers, each ISBN has an additional digit to increase redundancy and to spot errors. It is a number from '0' to '9'. If any single digit of the ISBN string changes, it will become invalid.,–⹁ 978-0-557-50469-5 `–´
- Returns:
- the checkdigit of the ISBN, e.g. '5'
-
toString
Returns the correctly hyphened ISBN-13 representation. -
toIso2108
Returns the human-readable ISO-2108 standard representation of this ISBN.- Returns:
- the official human-readable ISO-2108 standard representation, e.g. "ISBN 978-0-557-50469-5"
- Since:
- 1.1.2
-
toCompactString
Returns the compact ISBN-13 representation.- Returns:
- the compact ISBN-13 representation, e.g. "9780557504695"
-
toURI
Returns the URI for this ISBN.- Returns:
- the URI pointing to this ISBN, e.g. "urn:isbn:9780557504695"
-
equals
Two ISBN objects with the same ISBN-13 representation are treated equal. -
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<ISBN>
- See Also:
-
valueOf
Parses a given string input and returns an ISBN object.- Parameters:
isbn
- the ISBN string- Returns:
- the ISBN object
- Throws:
NumberFormatException
- if the input is not an ISBNIllegalArgumentException
-
updateRangeDefinition
public static void updateRangeDefinition()Load the ISBN definition from the latest release at github.com. On success this will overwrite the current (built-in) ISBN range definition.
To use this your application must be able to make outgoing https requests towardsraw.githubusercontent.com
.- Since:
- 1.1.0
-