Package nl.siegmann.epublib.domain
Class Spine
- java.lang.Object
-
- nl.siegmann.epublib.domain.Spine
-
- All Implemented Interfaces:
java.io.Serializable
public class Spine extends java.lang.Object implements java.io.SerializableThe 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:
TableOfContents, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDprivate java.util.List<SpineReference>spineReferencesprivate ResourcetocResource
-
Constructor Summary
Constructors Constructor Description Spine()Spine(java.util.List<SpineReference> spineReferences)Spine(TableOfContents tableOfContents)Creates a spine out of all the resources in the table of contents.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SpineReferenceaddResource(Resource resource)Adds the given resource to the spine references and returns it.SpineReferenceaddSpineReference(SpineReference spineReference)Adds the given spineReference to the spine references and returns it.static java.util.List<SpineReference>createSpineReferences(java.util.Collection<Resource> resources)intfindFirstResourceById(java.lang.String resourceId)Finds the first resource that has the given resourceId.ResourcegetResource(int index)Gets the resource at the given index.intgetResourceIndex(java.lang.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.java.util.List<SpineReference>getSpineReferences()ResourcegetTocResource()The resource containing the XML for the tableOfContents.booleanisEmpty()Whether the spine has any referencesvoidsetSpineReferences(java.util.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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
tocResource
private Resource tocResource
-
spineReferences
private java.util.List<SpineReference> spineReferences
-
-
Constructor Detail
-
Spine
public Spine()
-
Spine
public Spine(TableOfContents tableOfContents)
Creates a spine out of all the resources in the table of contents.- Parameters:
tableOfContents-
-
Spine
public Spine(java.util.List<SpineReference> spineReferences)
-
-
Method Detail
-
createSpineReferences
public static java.util.List<SpineReference> createSpineReferences(java.util.Collection<Resource> resources)
-
getSpineReferences
public java.util.List<SpineReference> getSpineReferences()
-
setSpineReferences
public void setSpineReferences(java.util.List<SpineReference> spineReferences)
-
getResource
public Resource getResource(int index)
Gets the resource at the given index. Null if not found.- Parameters:
index-- Returns:
- the resource at the given index.
-
findFirstResourceById
public int findFirstResourceById(java.lang.String resourceId)
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
public SpineReference addSpineReference(SpineReference spineReference)
Adds the given spineReference to the spine references and returns it.- Parameters:
spineReference-- Returns:
- the given spineReference
-
addResource
public SpineReference addResource(Resource resource)
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
public void setTocResource(Resource tocResource)
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
public Resource 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
public int getResourceIndex(Resource currentResource)
The position within the spine of the given resource.- Parameters:
currentResource-- Returns:
- something < 0 if not found.
-
getResourceIndex
public int getResourceIndex(java.lang.String resourceHref)
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
-
-