Class PackageDocumentReader
java.lang.Object
nl.siegmann.epublib.epub.PackageDocumentBase
nl.siegmann.epublib.epub.PackageDocumentReader
Reads the opf package document as defined by namespace http://www.idpf.org/2007/opf
-
Nested Class Summary
Nested classes/interfaces inherited from class PackageDocumentBase
PackageDocumentBase.DCAttributes, PackageDocumentBase.DCTags, PackageDocumentBase.OPFAttributes, PackageDocumentBase.OPFTags, PackageDocumentBase.OPFValues -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final String[]Fields inherited from class PackageDocumentBase
BOOK_ID_ID, dateFormat, NAMESPACE_DUBLIN_CORE, NAMESPACE_OPF, PREFIX_DUBLIN_CORE, PREFIX_OPF -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindCoverHrefs(Document packageDocument) Find all resources that have something to do with the coverpage and the cover image.(package private) static ResourcefindTableOfContentsResource(String tocResourceId, Resources resources) The spine tag should contain a 'toc' attribute with as value the resource id of the table of contents resource.(package private) static ResourcesStrips off the package prefixes up to the href of the packageHref.private static SpinegenerateSpineFromResources(Resources resources) Creates a spine out of all resources in the resources.static voidread(Resource packageResource, EpubReader epubReader, Book book, Resources resources) private static voidFinds the cover resource in the packageDocument and adds it to the book if found.private static voidreadGuide(Document packageDocument, EpubReader epubReader, Book book, Resources resources) Reads the book's guide.private static ResourcesreadManifest(Document packageDocument, String packageHref, EpubReader epubReader, Resources resources, Map<String, String> idMapping) Reads the manifest containing the resource ids, hrefs and mediatypes.private static SpineReads the document's spine, containing all sections in reading order.
-
Field Details
-
log
private static final org.slf4j.Logger log -
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 -
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
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
-
findTableOfContentsResource
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
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
-