Class Book

java.lang.Object
nl.siegmann.epublib.domain.Book
All Implemented Interfaces:
Serializable

public class Book extends Object implements Serializable
Representation of a Book. All resources of a Book (html, css, xml, fonts, images) are represented as Resources. See getResources() for access to these.
A Book as 3 indexes into these Resources, as per the epub specification.
Spine
these are the Resources to be shown when a user reads the book from start to finish.
Table of Contents
The table of contents. Table of Contents references may be in a different order and contain different Resources than the spine, and often do.
Guide
The Guide has references to a set of special Resources like the cover page, the Glossary, the copyright page, etc.

The complication is that these 3 indexes may and usually do point to different pages. A chapter may be split up in 2 pieces to fit it in to memory. Then the spine will contain both pieces, but the Table of Contents only the first. The Content page may be in the Table of Contents, the Guide, but not in the Spine. Etc.

invalid input: '<'svg id="svg2" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="568.44" width="670.93" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> invalid input: '<'rdf:RDF> invalid input: '<'cc:Work rdf:about=""> invalid input: '<'dc:format>image/svg+xmlinvalid input: '<'/dc:format> invalid input: '<'dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> invalid input: '<'dc:title/> invalid input: '<'/cc:Work> invalid input: '<'/rdf:RDF> invalid input: '<'text id="text4507" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="40px" font-style="normal" y="122.36219" x="88.571434" font-family="Sans" line-height="125%" fill="#000000">Spine invalid input: '<'text id="text4507-3" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="40px" font-style="normal" y="142.38702" x="262.85712" font-family="Sans" line-height="125%" fill="#000000">Table of Contents invalid input: '<'text id="text4507-5" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="40px" font-style="normal" y="208.1013" x="581.42853" font-family="Sans" line-height="125%" fill="#000000">Guide invalid input: '<'text id="text4577" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="188.89537" x="92.349854" font-family="Sans" line-height="125%" fill="#000000">Chapter 1 invalid input: '<'text id="text4577-0" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="255.01701" x="92.76873" font-family="Sans" line-height="125%" fill="#000000">Chapter 1 invalid input: '<'text id="text4577-0-3" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="278.23132" x="108.66158" font-family="Sans" line-height="125%" fill="#000000">Part 2 invalid input: '<'text id="text4577-0-6" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="327.33847" x="90.983017" font-family="Sans" line-height="125%" fill="#000000">Chapter 2 invalid input: '<'text id="text4577-6" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="215.1956" x="351.34015" font-family="Sans" line-height="125%" fill="#000000">Chapter 1 invalid input: '<'text id="text4577-0-6-1" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="276.62418" x="351.36185" font-family="Sans" line-height="125%" fill="#000000">Chapter 2 invalid input: '<'text id="text4577-6-5" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="278.05276" x="598.48297" font-family="Sans" line-height="125%" fill="#000000">Cover invalid input: '<'text id="text4507-1" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="40px" font-style="normal" y="418.66241" x="238.73047" font-family="Sans" line-height="125%" fill="#000000">Resources invalid input: '<'text id="text4577-6-5-4" style="letter-spacing:0px;word-spacing:0px;" font-weight="normal" xml:space="preserve" font-size="21.50233269px" font-style="normal" y="351.48663" x="594.909" font-family="Sans" line-height="125%" fill="#000000">Preface

See Also:
  • Field Details

  • Constructor Details

    • Book

      public Book()
  • Method Details

    • addSection

      public TOCReference addSection(TOCReference parentSection, String sectionTitle, Resource resource)
      Adds the resource to the table of contents of the book as a child section of the given parentSection
      Parameters:
      parentSection -
      sectionTitle -
      resource -
      Returns:
      The table of contents
    • generateSpineFromTableOfContents

      public void generateSpineFromTableOfContents()
    • addSection

      public TOCReference addSection(String title, Resource resource)
      Adds a resource to the book's set of resources, table of contents and if there is no resource with the id in the spine also adds it to the spine.
      Parameters:
      title -
      resource -
      Returns:
      The table of contents
    • getMetadata

      public Metadata getMetadata()
      The Book's metadata (titles, authors, etc)
      Returns:
      The Book's metadata (titles, authors, etc)
    • setMetadata

      public void setMetadata(Metadata metadata)
    • setResources

      public void setResources(Resources resources)
    • addResource

      public Resource addResource(Resource resource)
    • getResources

      public Resources getResources()
      The collection of all images, chapters, sections, xhtml files, stylesheets, etc that make up the book.
      Returns:
      The collection of all images, chapters, sections, xhtml files, stylesheets, etc that make up the book.
    • getSpine

      public Spine getSpine()
      The sections of the book that should be shown if a user reads the book from start to finish.
      Returns:
      The Spine
    • setSpine

      public void setSpine(Spine spine)
    • getTableOfContents

      public TableOfContents getTableOfContents()
      The Table of Contents of the book.
      Returns:
      The Table of Contents of the book.
    • setTableOfContents

      public void setTableOfContents(TableOfContents tableOfContents)
    • getCoverPage

      public Resource getCoverPage()
      The book's cover page as a Resource. An XHTML document containing a link to the cover image.
      Returns:
      The book's cover page as a Resource
    • setCoverPage

      public void setCoverPage(Resource coverPage)
    • getTitle

      public String getTitle()
      Gets the first non-blank title from the book's metadata.
      Returns:
      the first non-blank title from the book's metadata.
    • getCoverImage

      public Resource getCoverImage()
      The book's cover image.
      Returns:
      The book's cover image.
    • setCoverImage

      public void setCoverImage(Resource coverImage)
    • getGuide

      public Guide getGuide()
      The guide; contains references to special sections of the book like colophon, glossary, etc.
      Returns:
      The guide; contains references to special sections of the book like colophon, glossary, etc.
    • getContents

      public List<Resource> getContents()
      All Resources of the Book that can be reached via the Spine, the TableOfContents or the Guide.

      Consists of a list of "reachable" resources:

      • The coverpage
      • The resources of the Spine that are not already in the result
      • The resources of the Table of Contents that are not already in the result
      • The resources of the Guide that are not already in the result
      To get all html files that make up the epub file use getResources()
      Returns:
      All Resources of the Book that can be reached via the Spine, the TableOfContents or the Guide.
    • addToContentsResult

      private static void addToContentsResult(Resource resource, Map<String,Resource> allReachableResources)
    • getOpfResource

      public Resource getOpfResource()
    • setOpfResource

      public void setOpfResource(Resource opfResource)
    • setNcxResource

      public void setNcxResource(Resource ncxResource)
    • getNcxResource

      public Resource getNcxResource()