Class EpubBook
- java.lang.Object
-
- coza.opencollab.epub.creator.model.EpubBook
-
public class EpubBook extends Object
Representation of an EPUB book- Author:
- OpenCollab
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Content
addContent(byte[] contents, String mediaType, String href, boolean toc, boolean spine)
Creates and adds file Content to the bookboolean
addContent(Content content)
Adds content to the content list and checks the id.Content
addContent(InputStream contents, String mediaType, String href, boolean toc, boolean spine)
Creates and adds an InputStream to the bookvoid
addCoverImage(byte[] coverImage, String mediaType, String href)
Adds an file as the cover imageContent
addTextContent(String title, String href, String content)
Wraps a String in the HTML wrapper and adds create a content object that is added to the content list.String
getAuthor()
List<Content>
getContents()
EpubWriter
getEpubCreator()
String
getId()
List<Landmark>
getLandmarks()
String
getLanguage()
String
getTitle()
List<TocLink>
getTocLinks()
Set
getUniqueHrefs()
boolean
insertContent(Content content, int index)
Inserts content at a specific index.boolean
isAutoToc()
void
setAuthor(String author)
void
setAutoToc(boolean autoToc)
void
setContents(List<Content> contents)
void
setId(String id)
void
setLandmarks(List<Landmark> landmarks)
void
setLanguage(String language)
void
setTitle(String title)
void
setTocLinks(List<TocLink> tocLinks)
void
writeToFile(String fileName)
Creates the EPUB zip container and writes it to the Filevoid
writeToStream(OutputStream out)
Creates the EPUB zip container and writes it to the OutputStream
-
-
-
Constructor Detail
-
EpubBook
public EpubBook()
Constructs EPUBBook
-
EpubBook
public EpubBook(String language, String id, String title, String author)
Constructs EPUBBook- Parameters:
language
- the 2 letter language code set in the dc:language meta dataid
- the id used as the meta data dc:identifiertitle
- the title of the bookauthor
- the author, this is set as the meta data dc:creator value
-
-
Method Detail
-
addContent
public boolean addContent(Content content)
Adds content to the content list and checks the id. Only adds unique href's- Parameters:
content
- the EpubBook content - TOC, pages, files- Returns:
- boolean indicating if the content has been added
-
insertContent
public boolean insertContent(Content content, int index)
Inserts content at a specific index. Only adds unique href's- Parameters:
content
- the EpubBook content - TOC, pages, filesindex
- index where the content will be inserted- Returns:
- boolean indicating if the content has been added
-
addTextContent
public Content addTextContent(String title, String href, String content)
Wraps a String in the HTML wrapper and adds create a content object that is added to the content list. Returns null if the href is not unique- Parameters:
title
- the title of the pagehref
- used as unique linkcontent
- text content to be added- Returns:
- the Content object generated from the text
-
addContent
public Content addContent(byte[] contents, String mediaType, String href, boolean toc, boolean spine)
Creates and adds file Content to the book- Parameters:
contents
- the byte array contentmediaType
- the mime typehref
- used as unique linktoc
- flag whether it must be added to the TOCspine
- flag whether it must be added to the spine- Returns:
- a reference to the newly created Content object
-
addContent
public Content addContent(InputStream contents, String mediaType, String href, boolean toc, boolean spine) throws IOException
Creates and adds an InputStream to the book- Parameters:
contents
- the InputStream to the contentmediaType
- the mime typehref
- used as unique linktoc
- flag whether it must be added to the TOCspine
- flag whether it must be added to the spine- Returns:
- a reference to the newly created Content object
- Throws:
IOException
- if the InputStream can not be converted to byte[]
-
addCoverImage
public void addCoverImage(byte[] coverImage, String mediaType, String href)
Adds an file as the cover image- Parameters:
coverImage
- the cover imagemediaType
- the mime type of the cover imagehref
- used to name the cover image
-
writeToStream
public void writeToStream(OutputStream out) throws Exception
Creates the EPUB zip container and writes it to the OutputStream- Parameters:
out
- the OutputStream- Throws:
Exception
- if the content can not be zipped and written
-
writeToFile
public void writeToFile(String fileName) throws Exception
Creates the EPUB zip container and writes it to the File- Parameters:
fileName
- to store as- Throws:
Exception
- if the content can not be zipped and stored
-
setContents
public void setContents(List<Content> contents)
- Parameters:
contents
- the content to set
-
isAutoToc
public boolean isAutoToc()
- Returns:
- the autoToc
-
setAutoToc
public void setAutoToc(boolean autoToc)
- Parameters:
autoToc
- the autoToc to set
-
getLanguage
public String getLanguage()
- Returns:
- the language
-
setLanguage
public void setLanguage(String language)
- Parameters:
language
- the language to set
-
getId
public String getId()
- Returns:
- the id
-
setId
public void setId(String id)
- Parameters:
id
- the id to set
-
getTitle
public String getTitle()
- Returns:
- the title
-
setTitle
public void setTitle(String title)
- Parameters:
title
- the title to set
-
setTocLinks
public void setTocLinks(List<TocLink> tocLinks)
- Parameters:
tocLinks
- the tocLinks to set
-
setLandmarks
public void setLandmarks(List<Landmark> landmarks)
- Parameters:
landmarks
- the landmarks to set
-
getAuthor
public String getAuthor()
- Returns:
- the author
-
setAuthor
public void setAuthor(String author)
- Parameters:
author
- the author to set
-
getEpubCreator
public EpubWriter getEpubCreator()
- Returns:
- the epubCreator
-
getUniqueHrefs
public Set getUniqueHrefs()
- Returns:
- the uniqueHrefs
-
-