Class PackageDocumentReader

java.lang.Object
nl.siegmann.epublib.epub.PackageDocumentBase
nl.siegmann.epublib.epub.PackageDocumentReader

public class PackageDocumentReader extends PackageDocumentBase
Reads the opf package document as defined by namespace http://www.idpf.org/2007/opf
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • POSSIBLE_NCX_ITEM_IDS

      private static final String[] POSSIBLE_NCX_ITEM_IDS
  • Constructor Details

    • PackageDocumentReader

      public PackageDocumentReader()
  • Method Details

    • read

      public static void read(Resource packageResource, EpubReader epubReader, Book book, Resources resources) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException
      Throws:
      UnsupportedEncodingException
      SAXException
      IOException
      ParserConfigurationException
    • readManifest

      private static Resources readManifest(Document packageDocument, String packageHref, EpubReader epubReader, Resources resources, Map<String,String> idMapping)
      Reads the manifest containing the resource ids, hrefs and mediatypes.
      Parameters:
      packageDocument -
      packageHref -
      epubReader -
      book -
      resourcesByHref -
      Returns:
      a Map with resources, with their id's as key.
    • readGuide

      private static void readGuide(Document packageDocument, EpubReader epubReader, Book book, Resources resources)
      Reads the book's guide. Here some more attempts are made at finding the cover page.
      Parameters:
      packageDocument -
      epubReader -
      book -
      resources -
    • fixHrefs

      static Resources fixHrefs(String packageHref, Resources resourcesByHref)
      Strips off the package prefixes up to the href of the packageHref. Example: If the packageHref is "OEBPS/content.opf" then a resource href like "OEBPS/foo/bar.html" will be turned into "foo/bar.html"
      Parameters:
      packageHref -
      resourcesByHref -
      Returns:
      The stripped package href
    • readSpine

      private static Spine readSpine(Document packageDocument, Resources resources, Map<String,String> idMapping)
      Reads the document's spine, containing all sections in reading order.
      Parameters:
      packageDocument -
      epubReader -
      book -
      resourcesById -
      Returns:
      the document's spine, containing all sections in reading order.
    • generateSpineFromResources

      private static Spine generateSpineFromResources(Resources resources)
      Creates a spine out of all resources in the resources. The generated spine consists of all XHTML pages in order of their href.
      Parameters:
      resources -
      Returns:
      a spine created out of all resources in the resources.
    • findTableOfContentsResource

      static Resource findTableOfContentsResource(String tocResourceId, Resources resources)
      The spine tag should contain a 'toc' attribute with as value the resource id of the table of contents resource. Here we try several ways of finding this table of contents resource. We try the given attribute value, some often-used ones and finally look through all resources for the first resource with the table of contents mimetype.
      Parameters:
      spineElement -
      resourcesById -
      Returns:
      the Resource containing the table of contents
    • findCoverHrefs

      static Set<String> findCoverHrefs(Document packageDocument)
      Find all resources that have something to do with the coverpage and the cover image. Search the meta tags and the guide references
      Parameters:
      packageDocument -
      Returns:
      all resources that have something to do with the coverpage and the cover image.
    • readCover

      private static void readCover(Document packageDocument, Book book)
      Finds the cover resource in the packageDocument and adds it to the book if found. Keeps the cover resource in the resources map
      Parameters:
      packageDocument -
      book -
      resources -