Package nl.siegmann.epublib.domain
Class Book
- java.lang.Object
-
- nl.siegmann.epublib.domain.Book
-
- All Implemented Interfaces:
java.io.Serializable
public class Book extends java.lang.Object implements java.io.SerializableRepresentation 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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ResourcecoverImageprivate Guideguideprivate Metadatametadataprivate ResourcencxResourceprivate ResourceopfResourceprivate Resourcesresourcesprivate static longserialVersionUIDprivate Spinespineprivate TableOfContentstableOfContents
-
Constructor Summary
Constructors Constructor Description Book()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceaddResource(Resource resource)TOCReferenceaddSection(java.lang.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.TOCReferenceaddSection(TOCReference parentSection, java.lang.String sectionTitle, Resource resource)Adds the resource to the table of contents of the book as a child section of the given parentSectionprivate static voidaddToContentsResult(Resource resource, java.util.Map<java.lang.String,Resource> allReachableResources)voidgenerateSpineFromTableOfContents()java.util.List<Resource>getContents()All Resources of the Book that can be reached via the Spine, the TableOfContents or the Guide.ResourcegetCoverImage()The book's cover image.ResourcegetCoverPage()The book's cover page as a Resource.GuidegetGuide()The guide; contains references to special sections of the book like colophon, glossary, etc.MetadatagetMetadata()The Book's metadata (titles, authors, etc)ResourcegetNcxResource()ResourcegetOpfResource()ResourcesgetResources()The collection of all images, chapters, sections, xhtml files, stylesheets, etc that make up the book.SpinegetSpine()The sections of the book that should be shown if a user reads the book from start to finish.TableOfContentsgetTableOfContents()The Table of Contents of the book.java.lang.StringgetTitle()Gets the first non-blank title from the book's metadata.voidsetCoverImage(Resource coverImage)voidsetCoverPage(Resource coverPage)voidsetMetadata(Metadata metadata)voidsetNcxResource(Resource ncxResource)voidsetOpfResource(Resource opfResource)voidsetResources(Resources resources)voidsetSpine(Spine spine)voidsetTableOfContents(TableOfContents tableOfContents)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
resources
private Resources resources
-
metadata
private Metadata metadata
-
spine
private Spine spine
-
tableOfContents
private TableOfContents tableOfContents
-
guide
private Guide guide
-
opfResource
private Resource opfResource
-
ncxResource
private Resource ncxResource
-
coverImage
private Resource coverImage
-
-
Method Detail
-
addSection
public TOCReference addSection(TOCReference parentSection, java.lang.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(java.lang.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)
-
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 java.lang.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 java.util.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
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, java.util.Map<java.lang.String,Resource> allReachableResources)
-
getOpfResource
public Resource getOpfResource()
-
setOpfResource
public void setOpfResource(Resource opfResource)
-
setNcxResource
public void setNcxResource(Resource ncxResource)
-
getNcxResource
public Resource getNcxResource()
-
-