org.maxwe.epub.parser.impl.Content Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parser Show documentation
Show all versions of parser Show documentation
Parse EPub Metadata and HTML
package org.maxwe.epub.parser.impl;
import org.maxwe.epub.parser.core.IChapter;
import org.maxwe.epub.parser.core.IContent;
import org.maxwe.epub.parser.core.INavigation;
import java.util.LinkedList;
/**
* Created by Pengwei Ding on 2015-09-26 09:50.
* Email: [email protected] [email protected]
* Description: @TODO
*/
public class Content implements IContent {
private LinkedList navigates;
public Content(LinkedList navigates){
this.navigates = navigates;
}
public int getContentSize() {
return this.navigates.size();
}
public LinkedList getNavigation() {
return this.navigates;
}
public INavigation getNavigation(String navigationId) {
INavigation navigation = null;
for (INavigation nav:this.navigates){
if (nav.getId().equals(navigationId)){
navigation = nav;
break;
}
}
return navigation;
}
public INavigation getNavigation(int index) {
return this.navigates.get(index);
}
public IChapter navigateTo(INavigation navigation) throws Exception {
return new Chapter(navigation.getHref());
}
public IChapter navigateTo(String navigationId) throws Exception {
INavigation navigation = null;
for (INavigation nav:this.navigates){
if (nav.getId().equals(navigationId)){
navigation = nav;
break;
}
}
return navigateTo(navigation);
}
public IChapter navigateTo(int index) throws Exception {
return navigateTo(this.navigates.get(index));
}
}