Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.Resource


  private String getPackageResourceHref(Resources resources) {
    String defaultResult = "OEBPS/content.opf";
    String result = defaultResult;

    Resource containerResource = resources.remove("META-INF/container.xml");
    if(containerResource == null) {
      return result;
    }
    try {
      Document document = ResourceUtil.getAsDocument(containerResource);
View Full Code Here


  private static void ensureCoverPageGuideReferenceWritten(Guide guide,
      EpubWriter epubWriter, XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException {
    if (! (guide.getGuideReferencesByType(GuideReference.COVER).isEmpty())) {
      return;
    }
    Resource coverPage = guide.getCoverPage();
    if (coverPage != null) {
      writeGuideReference(new GuideReference(guide.getCoverPage(), GuideReference.COVER, GuideReference.COVER), serializer);
    }
  }
View Full Code Here

        continue;
      }
     
      String href = zipEntry.getName();
     
      Resource resource;
     
      if (shouldLoadLazy(href, lazyLoadedTypes)) {
        resource = new LazyResource(zipFile.getName(), zipEntry.getSize(), href);               
      } else {   
        resource = ResourceUtil.createResource(zipEntry, zipFile.getInputStream(zipEntry));
      }
     
      if(resource.getMediaType() == MediatypeService.XHTML) {
        resource.setInputEncoding(defaultHtmlEncoding);
      }
      result.add(resource);
    }
   
    return result;
View Full Code Here

      if((zipEntry == null) || (zipEntry == ERROR_ZIP_ENTRY) || zipEntry.isDirectory()) {
        continue;
      }
     
      // store resource
      Resource resource = ResourceUtil.createResource(zipEntry, zipInputStream);
      if(resource.getMediaType() == MediatypeService.XHTML) {
        resource.setInputEncoding(defaultHtmlEncoding);
      }
      result.add(resource);
    } while(zipEntry != null);

    return result;
View Full Code Here

        href = URLDecoder.decode(href, Constants.CHARACTER_ENCODING);
      } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage());
      }
      String mediaTypeName = DOMUtil.getAttribute(itemElement, NAMESPACE_OPF, OPFAttributes.media_type);
      Resource resource = resources.remove(href);
      if(resource == null) {
        log.error("resource with href '" + href + "' not found");
        continue;
      }
      resource.setId(id);
      MediaType mediaType = MediatypeService.getMediaTypeByName(mediaTypeName);
      if(mediaType != null) {
        resource.setMediaType(mediaType);
      }
      result.add(resource);
      idMapping.put(id, resource.getId());
    }
    return result;
 
View Full Code Here

      Element referenceElement = (Element) guideReferences.item(i);
      String resourceHref = DOMUtil.getAttribute(referenceElement, NAMESPACE_OPF, OPFAttributes.href);
      if (StringUtil.isBlank(resourceHref)) {
        continue;
      }
      Resource resource = resources.getByHref(StringUtil.substringBefore(resourceHref, Constants.FRAGMENT_SEPARATOR_CHAR));
      if (resource == null) {
        log.error("Guide is referencing resource with href " + resourceHref + " which could not be found");
        continue;
      }
      String type = DOMUtil.getAttribute(referenceElement, NAMESPACE_OPF, OPFAttributes.type);
View Full Code Here

      }
      String id = idMapping.get(itemref);
      if (id == null) {
        id = itemref;
      }
      Resource resource = resources.getByIdOrHref(id);
      if(resource == null) {
        log.error("resource with id \'" + id + "\' not found");
        continue;
      }
     
View Full Code Here

    Spine result = new Spine();
    List<String> resourceHrefs = new ArrayList<String>();
    resourceHrefs.addAll(resources.getAllHrefs());
    Collections.sort(resourceHrefs, String.CASE_INSENSITIVE_ORDER);
    for (String resourceHref: resourceHrefs) {
      Resource resource = resources.getByHref(resourceHref);
      if (resource.getMediaType() == MediatypeService.NCX) {
        result.setTocResource(resource);
      } else if (resource.getMediaType() == MediatypeService.XHTML) {
        result.addSpineReference(new SpineReference(resource));
      }
    }
    return result;
  }
View Full Code Here

   * @param resourcesById
   * @return the Resource containing the table of contents
   */
  private static Resource findTableOfContentsResource(Element spineElement, Resources resources) {
    String tocResourceId = DOMUtil.getAttribute(spineElement, NAMESPACE_OPF, OPFAttributes.toc);
    Resource tocResource = null;
    if (StringUtil.isNotBlank(tocResourceId)) {
      tocResource = resources.getByIdOrHref(tocResourceId);
    }
   
    if (tocResource != null) {
View Full Code Here

   */
  private static void readCover(Document packageDocument, Book book) {
   
    Collection<String> coverHrefs = findCoverHrefs(packageDocument);
    for (String coverHref: coverHrefs) {
      Resource resource = book.getResources().getByHref(coverHref);
      if (resource == null) {
        log.error("Cover resource " + coverHref + " not found");
        continue;
      }
      if (resource.getMediaType() == MediatypeService.XHTML) {
        book.setCoverPage(resource);
      } else if (MediatypeService.isBitmapImage(resource.getMediaType())) {
        book.setCoverImage(resource);
      }
    }
  }
View Full Code Here

TOP

Related Classes of nl.siegmann.epublib.domain.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.