Class ISBN

java.lang.Object
de.creativecouple.validation.isbn.ISBN
All Implemented Interfaces:
Serializable, Comparable<ISBN>

public final class ISBN extends Object implements Serializable, Comparable<ISBN>
Simple domain object, representing a single ISBN identifier.
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 Type
    Method
    Description
    int
     
    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.
    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.
    Each publication has a title identifier that is unique within the publisher's number range.
    int
     
    Returns the compact ISBN-13 representation.
    Returns the human-readable ISO-2108 standard representation of this ISBN.
    Returns the correctly hyphened ISBN-13 representation.
    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.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • getPrefix

      public String 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

      public String 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

      public String 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

      public String 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

      public String 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

      public String 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

      public String 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

      public String 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

      public String toString()
      Returns the correctly hyphened ISBN-13 representation.
      Overrides:
      toString in class Object
      Returns:
      the official ISBN-13 representation, e.g. "978-0-557-50469-5"
    • toIso2108

      public String 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

      public String toCompactString()
      Returns the compact ISBN-13 representation.
      Returns:
      the compact ISBN-13 representation, e.g. "9780557504695"
    • toURI

      public URI toURI()
      Returns the URI for this ISBN.
      Returns:
      the URI pointing to this ISBN, e.g. "urn:isbn:9780557504695"
    • equals

      public boolean equals(Object obj)
      Two ISBN objects with the same ISBN-13 representation are treated equal.
      Overrides:
      equals in class Object
      Returns:
      whether this ISBN is equal to another ISBN object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • compareTo

      public int compareTo(ISBN isbn)
      Specified by:
      compareTo in interface Comparable<ISBN>
      See Also:
    • valueOf

      public static ISBN valueOf(String isbn) throws IllegalArgumentException
      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 ISBN
      IllegalArgumentException
    • 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 towards raw.githubusercontent.com.
      Since:
      1.1.0