All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.maxwe.epub.parser.impl.Content Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy