Package nl.siegmann.epublib.domain
Class Spine
java.lang.Object
nl.siegmann.epublib.domain.Spine
- All Implemented Interfaces:
Serializable
The spine sections are the sections of the book in the order in which the book should be read.
This contrasts with the Table of Contents sections which is an index into the Book's sections.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longprivate List<SpineReference> private Resource -
Constructor Summary
ConstructorsConstructorDescriptionSpine()Spine(List<SpineReference> spineReferences) Spine(TableOfContents tableOfContents) Creates a spine out of all the resources in the table of contents. -
Method Summary
Modifier and TypeMethodDescriptionaddResource(Resource resource) Adds the given resource to the spine references and returns it.addSpineReference(SpineReference spineReference) Adds the given spineReference to the spine references and returns it.static List<SpineReference> createSpineReferences(Collection<Resource> resources) intfindFirstResourceById(String resourceId) Finds the first resource that has the given resourceId.getResource(int index) Gets the resource at the given index.intgetResourceIndex(String resourceHref) The first position within the spine of a resource with the given href.intgetResourceIndex(Resource currentResource) The position within the spine of the given resource.The resource containing the XML for the tableOfContents.booleanisEmpty()Whether the spine has any referencesvoidsetSpineReferences(List<SpineReference> spineReferences) voidsetTocResource(Resource tocResource) As per the epub file format the spine officially maintains a reference to the Table of Contents.intsize()The number of elements in the spine.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
tocResource
-
spineReferences
-
-
Constructor Details
-
Spine
public Spine() -
Spine
Creates a spine out of all the resources in the table of contents.- Parameters:
tableOfContents-
-
Spine
-
-
Method Details
-
createSpineReferences
-
getSpineReferences
-
setSpineReferences
-
getResource
Gets the resource at the given index. Null if not found.- Parameters:
index-- Returns:
- the resource at the given index.
-
findFirstResourceById
Finds the first resource that has the given resourceId. Null if not found.- Parameters:
resourceId-- Returns:
- the first resource that has the given resourceId.
-
addSpineReference
Adds the given spineReference to the spine references and returns it.- Parameters:
spineReference-- Returns:
- the given spineReference
-
addResource
Adds the given resource to the spine references and returns it.- Returns:
- the given spineReference
-
size
public int size()The number of elements in the spine.- Returns:
- The number of elements in the spine.
-
setTocResource
As per the epub file format the spine officially maintains a reference to the Table of Contents. The epubwriter will look for it here first, followed by some clever tricks to find it elsewhere if not found. Put it here to be sure of the expected behaviours.- Parameters:
tocResource-
-
getTocResource
The resource containing the XML for the tableOfContents. When saving an epub file this resource needs to be in this place.- Returns:
- The resource containing the XML for the tableOfContents.
-
getResourceIndex
The position within the spine of the given resource.- Parameters:
currentResource-- Returns:
- something < 0 if not found.
-
getResourceIndex
The first position within the spine of a resource with the given href.- Returns:
- something < 0 if not found.
-
isEmpty
public boolean isEmpty()Whether the spine has any references- Returns:
- Whether the spine has any references
-