Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.Resource


    String version = "2005-1";
   
  }
 
  public static Resource read(Book book, EpubReader epubReader) {
    Resource ncxResource = null;
    if(book.getSpine().getTocResource() == null) {
      log.error("Book does not contain a table of contents file");
      return ncxResource;
    }
    try {
View Full Code Here


      tocResourceRoot = tocResourceRoot + "/";
    }
    String reference = 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);
View Full Code Here

  }
  public static Resource createNCXResource(List<Identifier> identifiers, String title, List<Author> authors, TableOfContents tableOfContents) throws IllegalArgumentException, IllegalStateException, IOException {
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    XmlSerializer out = EpubProcessorSupport.createXmlSerializer(data);
    write(out, identifiers, title, authors, tableOfContents);
    Resource resource = new Resource(NCX_ITEM_ID, data.toByteArray(), DEFAULT_NCX_HREF, MediatypeService.NCX);
    return resource;
 
View Full Code Here

      if(file.getType() == FileType.FOLDER) {
        processSubdirectory(rootDir, file, sections, resources, inputEncoding);
      } else if (MediatypeService.determineMediaType(file.getName().getBaseName()) == null) {
        continue;
      } else {
        Resource resource = VFSUtil.createResource(rootDir, file, inputEncoding);
        if(resource == null) {
          continue;
        }
        resources.add(resource);
        if(MediatypeService.XHTML == resource.getMediaType()) {
          TOCReference section = new TOCReference(file.getName().getBaseName(), resource);
          sections.add(section);
        }
      }
    }
View Full Code Here

      throws IOException {
    List<TOCReference> childTOCReferences = new ArrayList<TOCReference>();
    processDirectory(rootDir, file, childTOCReferences, resources, inputEncoding);
    if(! childTOCReferences.isEmpty()) {
      String sectionName = file.getName().getBaseName();
      Resource sectionResource = ResourceUtil.createResource(sectionName, VFSUtil.calculateHref(rootDir,file));
      resources.add(sectionResource);
      TOCReference section = new TOCReference(sectionName, sectionResource);
      section.setChildren(childTOCReferences);
      sections.add(section);
    }
View Full Code Here

      String href = file.getName().toString().substring(rootDir.getName().toString().length() + 1);
      byte[] resourceData = IOUtils.toByteArray(file.getContent().getInputStream());
      if(mediaType == MediatypeService.XHTML && ! nl.siegmann.epublib.Constants.CHARACTER_ENCODING.equalsIgnoreCase(inputEncoding)) {
        resourceData = ResourceUtil.recode(inputEncoding, nl.siegmann.epublib.Constants.CHARACTER_ENCODING, resourceData);
      }
      Resource fileResource = new Resource(null, resourceData, href, mediaType);
      result.add(fileResource);
    }
    return result;
  }
View Full Code Here

    return book;
  }

  private static List<SpineReference> checkSpineReferences(Spine spine) {
    List<SpineReference> result = new ArrayList<SpineReference>(spine.size());
    Resource previousResource = null;
    for(SpineReference spineReference: spine.getSpineReferences()) {
      if(spineReference.getResource() == null
          || StringUtils.isBlank(spineReference.getResource().getHref())) {
        continue;
      }
      if(previousResource == null
          || spineReference.getResource() == null
          || ( ! (spineReference.getResource().getHref().equals(previousResource.getHref())))) {
        result.add(spineReference);
      }
      previousResource = spineReference.getResource();
    }
    return result;
View Full Code Here

    if (resourceHref.startsWith("#")) {
      scrollToNamedAnchor(resourceHref.substring(1));
      return;
    }

    Resource resource = navigator.getBook().getResources().getByHref(resourceHref);
    if (resource == null) {
      log.error("Resource with url " + resourceHref + " not found");
    } else {
      navigator.gotoResource(resource, this);
    }
View Full Code Here

   
    // get the image resource href
    String resourceHref = getResourceHref(imageURL);
   
    // find the image resource in the book resources
    Resource imageResource = book.getResources().getByHref(resourceHref);
    if (imageResource == null) {
      return result;
    }
   
    // create an image from the resource and add it to the cache
View Full Code Here

    MediaType mediaType = MediatypeService.determineMediaType(file.getName().getBaseName());
    if(mediaType == null) {
      return null;
    }
    String href = calculateHref(rootDir, file);
    Resource result = new Resource(null, IOUtils.toByteArray(file.getContent().getInputStream()), href, mediaType);
    result.setInputEncoding(inputEncoding);
    return result;
  }
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.