EpubChapter
EpubChapter class represents a chapter in an EPUB book, containing chapter title, content path, and other related information.
Constructor
public EpubChapter()Creates a new EpubChapter instance.
public EpubChapter(String title, String content)Creates a new EpubChapter instance.
Parameters:
title: Chapter titlecontent: Chapter content path
public EpubChapter(String id, String title, String content)Creates a new EpubChapter instance.
Parameters:
id: Chapter IDtitle: Chapter titlecontent: Chapter content path
Main Methods
getId()
public String getId()Gets chapter ID.
Returns:
String: Chapter ID
setId()
public void setId(String id)Sets chapter ID.
Parameters:
id: Chapter ID
getTitle()
public String getTitle()Gets chapter title.
Returns:
String: Chapter title
setTitle()
public void setTitle(String title)Sets chapter title.
Parameters:
title: Chapter title
getContent()
public String getContent()Gets chapter content path.
Returns:
String: Chapter content path
setContent()
public void setContent(String content)Sets chapter content path.
Parameters:
content: Chapter content path
getHref()
public String getHref()Gets chapter's href attribute.
Returns:
String: Chapter's href attribute
setHref()
public void setHref(String href)Sets chapter's href attribute.
Parameters:
href: Chapter's href attribute
getMediaType()
public String getMediaType()Gets chapter's media type.
Returns:
String: Chapter's media type (e.g., "application/xhtml+xml")
setMediaType()
public void setMediaType(String mediaType)Sets chapter's media type.
Parameters:
mediaType: Chapter's media type
getParent()
public EpubChapter getParent()Gets chapter's parent chapter.
Returns:
EpubChapter: Parent chapter object, or null if it's a top-level chapter
setParent()
public void setParent(EpubChapter parent)Sets chapter's parent chapter.
Parameters:
parent: Parent chapter object
getChildren()
public List<EpubChapter> getChildren()Gets chapter's child chapter list.
Returns:
List<EpubChapter>: Child chapter list
addChild()
public void addChild(EpubChapter child)Adds child chapter.
Parameters:
child: Child chapter object
hasChildren()
public boolean hasChildren()Checks if chapter has child chapters.
Returns:
boolean: Returns true if chapter has child chapters, otherwise false
getDepth()
public int getDepth()Gets chapter's depth (level in the table of contents tree).
Returns:
int: Chapter depth, root chapter is 0
getPath()
public String getPath()Gets chapter's full path.
Returns:
String: Chapter's full path
getOrder()
public int getOrder()Gets chapter's order in the book.
Returns:
int: Chapter order
setOrder()
public void setOrder(int order)Sets chapter's order in the book.
Parameters:
order: Chapter order
getPlayOrder()
public int getPlayOrder()Gets chapter's play order (for TTS or audio).
Returns:
int: Chapter play order
setPlayOrder()
public void setPlayOrder(int playOrder)Sets chapter's play order (for TTS or audio).
Parameters:
playOrder: Chapter play order
getNavPoint()
public Object getNavPoint()Gets navigation point object (internal use).
Returns:
Object: Navigation point object
setNavPoint()
public void setNavPoint(Object navPoint)Sets navigation point object (internal use).
Parameters:
navPoint: Navigation point object
getAnchor()
public String getAnchor()Gets chapter's anchor (specific position within the chapter).
Returns:
String: Chapter's anchor
setAnchor()
public void setAnchor(String anchor)Sets chapter's anchor (specific position within the chapter).
Parameters:
anchor: Chapter's anchor
getChildrenCount()
public int getChildrenCount()Gets child chapter count.
Returns:
int: Child chapter count
getAllChildren()
public List<EpubChapter> getAllChildren()Gets all child chapters (including nested child chapters).
Returns:
List<EpubChapter>: All child chapters list
isNested()
public boolean isNested()Checks if chapter is nested (has parent chapter).
Returns:
boolean: Returns true if chapter is nested, otherwise false
findChildById()
public EpubChapter findChildById(String id)Finds specified ID chapter in child chapters.
Parameters:
id: Chapter ID to find
Returns:
EpubChapter: Found chapter object, or null if not found
findChildByTitle()
public EpubChapter findChildByTitle(String title)Finds specified title chapter in child chapters.
Parameters:
title: Chapter title to find
Returns:
EpubChapter: Found chapter object, or null if not found
findChildByPath()
public EpubChapter findChildByPath(String path)Finds specified path chapter in child chapters.
Parameters:
path: Chapter path to find
Returns:
EpubChapter: Found chapter object, or null if not found
getContentText()
public String getContentText(File epubFile) throws EpubExceptionGets chapter content's text representation.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
String: Chapter content's text representation
Throws:
EpubException: Error occurred during content reading
getContentDocument()
public Document getContentDocument(File epubFile) throws EpubExceptionGets chapter content's JSoup Document object.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
Document: Chapter content's JSoup Document object
Throws:
EpubException: Error occurred during content parsing
getFirstParagraph()
public String getFirstParagraph(File epubFile) throws EpubExceptionGets chapter's first paragraph content.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
String: Chapter's first paragraph content
Throws:
EpubException: Error occurred during content reading
getHeadings()
public List<String> getHeadings(File epubFile) throws EpubExceptionGets all headings in the chapter.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
List<String>: Chapter's heading list
Throws:
EpubException: Error occurred during content reading
getImages()
public List<String> getImages(File epubFile) throws EpubExceptionGets all image paths referenced in the chapter.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
List<String>: Chapter's image path list
Throws:
EpubException: Error occurred during content reading
getWordCount()
public int getWordCount(File epubFile) throws EpubExceptionGets chapter's word count.
Parameters:
epubFile: EPUB file containing the chapter
Returns:
int: Chapter's word count
Throws:
EpubException: Error occurred during content reading
toString()
public String toString()Returns string representation of chapter.
Returns:
String: String representation of chapter