本文整理汇总了Java中nl.siegmann.epublib.domain.Resource.getHref方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getHref方法的具体用法?Java Resource.getHref怎么用?Java Resource.getHref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.siegmann.epublib.domain.Resource
的用法示例。
在下文中一共展示了Resource.getHref方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
public static void read(Resource packageResource, EpubReader epubReader, Book book, Resources resources) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException {
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
String packageHref = packageResource.getHref();
resources = fixHrefs(packageHref, resources);
readGuide(packageDocument, epubReader, book, resources);
// Books sometimes use non-identifier ids. We map these here to legal ones
Map<String, String> idMapping = new HashMap<String, String>();
resources = readManifest(packageDocument, packageHref, epubReader, resources, idMapping);
book.setResources(resources);
readCover(packageDocument, book);
book.setMetadata(PackageDocumentMetadataReader.readMetadata(packageDocument));
book.setSpine(readSpine(packageDocument, epubReader, book.getResources(), idMapping));
// if we did not find a cover page then we make the first page of the book the cover page
if (book.getCoverPage() == null && book.getSpine().size() > 0) {
book.setCoverPage(book.getSpine().getResource(0));
}
}
示例2: addResource
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
/**
* Adds a new resource.
* @param resource
*/
private void addResource( Resource resource ) {
SpineEntry newEntry = new SpineEntry();
newEntry.title = resource.getTitle();
newEntry.resource = resource;
newEntry.href = resource.getHref();
newEntry.size = (int) resource.getSize();
entries.add(newEntry);
}
示例3: resolveHref
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
/**
* Resolves a href relative to the current resource.
*
* @param href
* @return
*/
public String resolveHref( String href ) {
Option<Resource> res = getCurrentResource();
if (! isEmpty(res) ) {
Resource actualResource = res.unsafeGet();
if ( actualResource.getHref() != null ) {
return resolveHref(href, actualResource.getHref());
}
}
return href;
}
示例4: getTitle
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
public static String getTitle(Resource resource) {
if (resource == null) {
return "";
}
if (resource.getMediaType() != MediatypeService.XHTML) {
return resource.getHref();
}
String title = findTitleFromXhtml(resource);
if (title == null) {
title = "";
}
return title;
}
示例5: getResourceContent
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
/**
* returns the file input stream of a resources located in an epub
* in difference to {@link Resource#getData()} the stream is not cached in memory
*/
public InputStream getResourceContent(Resource resource) throws FileNotFoundException {
File file = new File(getOpfPath(), resource.getHref());
return new FileInputStream(file);
}