• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TOCReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中nl.siegmann.epublib.domain.TOCReference的典型用法代码示例。如果您正苦于以下问题:Java TOCReference类的具体用法?Java TOCReference怎么用?Java TOCReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TOCReference类属于nl.siegmann.epublib.domain包,在下文中一共展示了TOCReference类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadBook

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private void loadBook() {

        try {
            // 打开书籍
            EpubReader reader = new EpubReader();
            InputStream is = new FileInputStream(mFilePath);
            mBook = reader.readEpub(is);

            mTocReferences = (ArrayList<TOCReference>) mBook.getTableOfContents().getTocReferences();
            mSpineReferences = mBook.getSpine().getSpineReferences();

            setSpineReferenceTitle();

            // 解压epub至缓存目录
            FileUtils.unzipFile(mFilePath, Constant.PATH_EPUB + "/" + mFileName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:20,代码来源:ReadEPubActivity.java


示例2: onBindViewHolder

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
@Override
public void onBindViewHolder(VH holder, int position) {
    TOCReference tocReference = tableOfContents.get(position);
    String title = tocReference.getTitle();
    if (title == null) {
        title = "Chapter " + (position + 1);
    }
    holder.binding.chapterTitle.setText(title);

    if (position == currentTocPosition) {
        holder.binding.chapterTitle.setBackgroundColor(Color.LTGRAY);
    } else {
        holder.binding.chapterTitle.setBackgroundColor(Color.TRANSPARENT);
    }

    holder.binding.getRoot().setOnClickListener(v -> {
        // search correct chapter (spine position) for toc entry
        int spinePosition = epub.getSpinePositionForTocReference(tocReference);
        if (spinePosition >= 0) {
            jumpToChapter.onNext(spinePosition);
        }
    });

}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:25,代码来源:TableOfContentsAdapter.java


示例3: flatten

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private void flatten(List<TOCReference> refs, List<TocEntry> entries,
		int level) {

	if (spine == null || refs == null || refs.isEmpty()) {
		return;
	}

	for (TOCReference ref : refs) {

		String title = "";

		for (int i = 0; i < level; i++) {
			title += "  ";
		}

		title += ref.getTitle();

		if (ref.getResource() != null) {
			entries.add(new TocEntry(title, spine.resolveTocHref(ref
					.getCompleteHref())));
		}

		flatten(ref.getChildren(), entries, level + 1);
	}
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:26,代码来源:BookView.java


示例4: parseChm

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
public static Book parseChm(FileObject chmRootDir, String inputHtmlEncoding)
		throws IOException, ParserConfigurationException,
		XPathExpressionException {
	Book result = new Book();
	result.getMetadata().addTitle(findTitle(chmRootDir));
	FileObject hhcFileObject = findHhcFileObject(chmRootDir);
	if(hhcFileObject == null) {
		throw new IllegalArgumentException("No index file found in directory " + chmRootDir + ". (Looked for file ending with extension '.hhc'");
	}
	if(inputHtmlEncoding == null) {
		inputHtmlEncoding = DEFAULT_CHM_HTML_INPUT_ENCODING;
	}
	Resources resources = findResources(chmRootDir, inputHtmlEncoding);
	List<TOCReference> tocReferences = HHCParser.parseHhc(hhcFileObject.getContent().getInputStream(), resources);
	result.setTableOfContents(new TableOfContents(tocReferences));
	result.setResources(resources);
	result.generateSpineFromTableOfContents();
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:20,代码来源:ChmParser.java


示例5: processUlNode

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static List<TOCReference> processUlNode(Node ulNode, Resources resources) {
	List<TOCReference> result = new ArrayList<TOCReference>();
	NodeList children = ulNode.getChildNodes();
	for(int i = 0; i < children.getLength(); i++) {
		Node node = children.item(i);
		if(node.getNodeName().equals("li")) {
			List<TOCReference> section = processLiNode(node, resources);
			result.addAll(section);
		} else if(node.getNodeName().equals("ul")) {
			List<TOCReference> childTOCReferences = processUlNode(node, resources);
			if(result.isEmpty()) {
				result = childTOCReferences;
			} else {
				result.get(result.size() - 1).getChildren().addAll(childTOCReferences);
			}
		}
	}
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:20,代码来源:HHCParser.java


示例6: processLiNode

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static List<TOCReference> processLiNode(Node liNode, Resources resources) {
	List<TOCReference> result = new ArrayList<TOCReference>();
	NodeList children = liNode.getChildNodes();
	for(int i = 0; i < children.getLength(); i++) {
		Node node = children.item(i);
		if(node.getNodeName().equals("object")) {
			TOCReference section = processObjectNode(node, resources);
			if(section != null) {
				result.add(section);
			}
		} else if(node.getNodeName().equals("ul")) {
			List<TOCReference> childTOCReferences = processUlNode(node, resources);
			if(result.isEmpty()) {
				result = childTOCReferences;
			} else {
				result.get(result.size() - 1).getChildren().addAll(childTOCReferences);
			}
		}
	}
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:22,代码来源:HHCParser.java


示例7: readTOCReferences

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static List<TOCReference> readTOCReferences(NodeList navpoints, Book book) {
	if(navpoints == null) {
		return new ArrayList<TOCReference>();
	}
	List<TOCReference> result = new ArrayList<TOCReference>(navpoints.getLength());
	for(int i = 0; i < navpoints.getLength(); i++) {
		Node node = navpoints.item(i);
		if (node.getNodeType() != Document.ELEMENT_NODE) {
			continue;
		}
		if (! (node.getLocalName().equals(NCXTags.navPoint))) {
			continue;
		}
		TOCReference tocReference = readTOCReference((Element) node, book);
		result.add(tocReference);
	}
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:19,代码来源:NCXDocument.java


示例8: readTOCReference

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static TOCReference readTOCReference(Element navpointElement, Book book) {
	String label = readNavLabel(navpointElement);
	String tocResourceRoot = StringUtil.substringBeforeLast(book.getSpine().getTocResource().getHref(), '/');
	if (tocResourceRoot.length() == book.getSpine().getTocResource().getHref().length()) {
		tocResourceRoot = "";
	} else {
		tocResourceRoot = tocResourceRoot + "/";
	}
	String reference = StringUtil.collapsePathDots(tocResourceRoot + readNavReference(navpointElement));
	String href = StringUtil.substringBefore(reference, Constants.FRAGMENT_SEPARATOR_CHAR);
	String fragmentId = StringUtil.substringAfter(reference, Constants.FRAGMENT_SEPARATOR_CHAR);
	Resource resource = book.getResources().getByHref(href);
	if (resource == null) {
		log.error("Resource with href " + href + " in NCX document not found");
	}
	TOCReference result = new TOCReference(label, resource, fragmentId);
	readTOCReferences(navpointElement.getChildNodes(), book);
	result.setChildren(readTOCReferences(navpointElement.getChildNodes(), book));
	return result;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:21,代码来源:NCXDocument.java


示例9: writeNavPoints

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static int writeNavPoints(List<TOCReference> tocReferences, int playOrder,
		XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException  {
	for(TOCReference tocReference: tocReferences) {
		if (tocReference.getResource() == null) {
			playOrder = writeNavPoints(tocReference.getChildren(), playOrder, serializer);
			continue;
		}
		writeNavPointStart(tocReference, playOrder, serializer);
		playOrder++;
		if(! tocReference.getChildren().isEmpty()) {
			playOrder = writeNavPoints(tocReference.getChildren(), playOrder, serializer);
		}
		writeNavPointEnd(tocReference, serializer);
	}
	return playOrder;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:17,代码来源:NCXDocument.java


示例10: getSpinePositionForTocReference

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
/**
 * @return -1 if toc position not found
 */
public int getSpinePositionForTocReference(TOCReference tocReference) {
    List<SpineReference> spineReferences = getBook().getSpine().getSpineReferences();
    for (int i = 0; i < spineReferences.size(); i++) {
        SpineReference spineReference = spineReferences.get(i);
        if (tocReference.getResourceId().equals(spineReference.getResourceId())) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:14,代码来源:Epub.java


示例11: getTocPositionForSpinePosition

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
/**
 * @return -1 if spine position not found
 */
public int getTocPositionForSpinePosition(int spinePosition) {
    List<TOCReference> tocReferences = getBook().getTableOfContents().getTocReferences();
    for (int i = 0; i < tocReferences.size(); i++) {
        TOCReference tocReference = tocReferences.get(i);
        int spinePositionForTocReference = getSpinePositionForTocReference(tocReference);
        if (spinePositionForTocReference == spinePosition) {
            return i;
        }
        if (spinePositionForTocReference > spinePosition) {
            return i - 1;
        }
    }
    return -1;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:18,代码来源:Epub.java


示例12: fixMissingResources

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private void fixMissingResources(Collection<TOCReference> tocReferences, Book book) {
	for (TOCReference tocReference:  tocReferences) {
		if (tocReference.getResource() == null) {
			
		}
	}
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:8,代码来源:FixMissingResourceBookProcessor.java


示例13: getTitle

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private String getTitle(TOCReference tocReference, Book book, XPath xpath) throws IOException, XPathExpressionException {
	Resource resource = tocReference.getResource();
	if(resource == null) {
		return null;
	}
	InputSource inputSource = new InputSource(resource.getInputStream());
	String title = xpath.evaluate("/html/head/title", inputSource);
	return title;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:10,代码来源:SectionTitleBookProcessor.java


示例14: parseHhc

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
public static List<TOCReference> parseHhc(InputStream hhcFile, Resources resources) throws IOException, ParserConfigurationException,	XPathExpressionException {
	HtmlCleaner htmlCleaner = new HtmlCleaner();
	CleanerProperties props = htmlCleaner.getProperties();
	TagNode node = htmlCleaner.clean(hhcFile);
	Document hhcDocument = new DomSerializer(props).createDOM(node);
	XPath xpath = XPathFactory.newInstance().newXPath();
	Node ulNode = (Node) xpath.evaluate("body/ul", hhcDocument
			.getDocumentElement(), XPathConstants.NODE);
	List<TOCReference> sections = processUlNode(ulNode, resources);
	return sections;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:12,代码来源:HHCParser.java


示例15: writeNavPointStart

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static void writeNavPointStart(TOCReference tocReference, int playOrder, XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException  {
	serializer.startTag(NAMESPACE_NCX, NCXTags.navPoint);
	serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, NCXAttributes.id, "navPoint-" + playOrder);
	serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, NCXAttributes.playOrder, String.valueOf(playOrder));
	serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, NCXAttributes.clazz, NCXAttributeValues.chapter);
	serializer.startTag(NAMESPACE_NCX, NCXTags.navLabel);
	serializer.startTag(NAMESPACE_NCX, NCXTags.text);
	serializer.text(tocReference.getTitle());
	serializer.endTag(NAMESPACE_NCX, NCXTags.text);
	serializer.endTag(NAMESPACE_NCX, NCXTags.navLabel);
	serializer.startTag(NAMESPACE_NCX, NCXTags.content);
	serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, NCXAttributes.src, tocReference.getCompleteHref());
	serializer.endTag(NAMESPACE_NCX, NCXTags.content);
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:15,代码来源:NCXDocument.java


示例16: createTocFile

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
public void createTocFile() {
	List<TOCReference> tmp;
	TableOfContents toc = book.getTableOfContents();
	String html = "<html><body><ul>";

	tmp = toc.getTocReferences();

	if (tmp.size() > 0) {
		html += getS(R.string.tocReference);
		for (int i = 0; i < tmp.size(); i++) {
			String path = "file://" + location + decompressedFolder + "/"
					+ pathOPF + "/" + tmp.get(i).getCompleteHref();

			html += "<li>" + "<a href=\"" + path + "\">"
					+ tmp.get(i).getTitle() + "</a>" + "</li>";

			// pre-order traversal?
			List<TOCReference> children = tmp.get(i).getChildren();

			for (int j = 0; j < children.size(); j++)
				html += r_createTocFile(children.get(j));

		}
	}

	html += getS(R.string.tablebodyhtmlClose);

	// write down the html file
	String filePath = location + decompressedFolder + "/Toc.html";
	try {
		File file = new File(filePath);
		FileWriter fw = new FileWriter(file);
		fw.write(html);
		fw.flush();
		fw.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:pettarin,项目名称:epub3reader,代码行数:40,代码来源:EpubManipulator.java


示例17: fillToc

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private void fillToc(List<TOCReference> tocReferences) {
    for (TOCReference tocReference : tocReferences) {
        tableOfContents.add(tocReference);
        fillToc(tocReference.getChildren());
    }
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:7,代码来源:TableOfContentsAdapter.java


示例18: writeNavPointEnd

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
private static void writeNavPointEnd(TOCReference tocReference, XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException  {
	serializer.endTag(NAMESPACE_NCX, NCXTags.navPoint);
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:4,代码来源:NCXDocument.java


示例19: r_createTocFile

import nl.siegmann.epublib.domain.TOCReference; //导入依赖的package包/类
public String r_createTocFile(TOCReference e) {

		String childrenPath = "file://" + location + decompressedFolder + "/"
				+ pathOPF + "/" + e.getCompleteHref();

		String html = "<ul><li>" + "<a href=\"" + childrenPath + "\">"
				+ e.getTitle() + "</a>" + "</li></ul>";

		List<TOCReference> children = e.getChildren();

		for (int j = 0; j < children.size(); j++)
			html += r_createTocFile(children.get(j));

		return html;
	}
 
开发者ID:pettarin,项目名称:epub3reader,代码行数:16,代码来源:EpubManipulator.java



注:本文中的nl.siegmann.epublib.domain.TOCReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ButtonSize类代码示例发布时间:2022-05-22
下一篇:
Java Joinable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap