Class Spine

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

public class Spine extends Object implements 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 Details

  • Constructor Details

    • 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(List<SpineReference> spineReferences)
  • Method Details

    • createSpineReferences

      public static List<SpineReference> createSpineReferences(Collection<Resource> resources)
    • getSpineReferences

      public List<SpineReference> getSpineReferences()
    • setSpineReferences

      public void setSpineReferences(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(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(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