Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.Book


      assertTrue(e.getMessage(), false);
    }
  }
 
  public void testSimpleDocument3() {
    Book book = new Book();
    String testInput = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>test page</title></head><body>Hello, world! ß</body></html>";
    try {
      Resource resource = new Resource(null, testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html", MediatypeService.XHTML, Constants.CHARACTER_ENCODING);
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String result = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(Constants.DOCTYPE_XHTML + "\n" + testInput, result);
    } catch (IOException e) {
View Full Code Here


      assertTrue(e.getMessage(), false);
    }
  }
 
  public void testSimpleDocument4() {
    Book book = new Book();
    String testInput = "<html><head><title>title</title></head><body>Hello, world!\nHow are you ?</html>";
    String expectedResult = Constants.DOCTYPE_XHTML + "\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>title</title></head><body>Hello, world!\nHow are you ?</body></html>";
    try {
      Resource resource = new Resource(testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html");
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String actualResult = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(expectedResult, actualResult);
    } catch (IOException e) {
View Full Code Here

    }
  }


  public void testMetaContentType() {
    Book book = new Book();
    String testInput = "<html><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/></head><body>Hello, world!</html>";
    String expectedResult = Constants.DOCTYPE_XHTML + "\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + Constants.CHARACTER_ENCODING + "\" /></head><body>Hello, world!</body></html>";
    try {
      Resource resource = new Resource(testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html");
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String actualResult = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(expectedResult, actualResult);
    } catch (IOException e) {
View Full Code Here

      assertTrue(e.getMessage(), false);
    }
  }
 
  public void testDocType1() {
    Book book = new Book();
    String testInput = "<html><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/></head><body>Hello, world!</html>";
    String expectedResult = Constants.DOCTYPE_XHTML + "\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + Constants.CHARACTER_ENCODING + "\" /></head><body>Hello, world!</body></html>";
    try {
      Resource resource = new Resource(testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html");
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String actualResult = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(expectedResult, actualResult);
    } catch (IOException e) {
View Full Code Here

      assertTrue(e.getMessage(), false);
    }
  }

  public void testDocType2() {
    Book book = new Book();
    String testInput = Constants.DOCTYPE_XHTML + "\n<html><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/></head><body>Hello, world!</html>";
    String expectedResult = Constants.DOCTYPE_XHTML + "\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>title</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + Constants.CHARACTER_ENCODING + "\" /></head><body>Hello, world!</body></html>";
    try {
      Resource resource = new Resource(testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html");
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String actualResult = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(expectedResult, actualResult);
    } catch (IOException e) {
View Full Code Here

      assertTrue(e.getMessage(), false);
    }
  }

  public void testXmlNS() {
    Book book = new Book();
    String testInput = "<html><head><title>title</title></head><body xmlns:xml=\"xml\">Hello, world!</html>";
    String expectedResult = Constants.DOCTYPE_XHTML + "\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>title</title></head><body>Hello, world!</body></html>";
    try {
      Resource resource = new Resource(testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html");
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String actualResult = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(expectedResult, actualResult);
    } catch (IOException e) {
View Full Code Here

    } catch (IOException e) {
      assertTrue(e.getMessage(), false);
    }
  }
  public void testApos() {
    Book book = new Book();
    String testInput = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>test page</title></head><body>'hi'</body></html>";
    try {
      Resource resource = new Resource(null, testInput.getBytes(Constants.CHARACTER_ENCODING), "test.html", MediatypeService.XHTML, Constants.CHARACTER_ENCODING);
      book.getResources().add(resource);
      HtmlCleanerBookProcessor htmlCleanerBookProcessor = new HtmlCleanerBookProcessor();
      byte[] processedHtml = htmlCleanerBookProcessor.processHtml(resource, book, Constants.CHARACTER_ENCODING);
      String result = new String(processedHtml, Constants.CHARACTER_ENCODING);
      assertEquals(Constants.DOCTYPE_XHTML + "\n" + testInput, result);
    } catch (IOException e) {
View Full Code Here

    Resources resources = ResourcesLoader.loadResources(zipFile, encoding, lazyLoadedTypes);
    return readEpub(resources);
  }
 
    public Book readEpub(Resources resources) throws IOException{
        return readEpub(resources, new Book());
    }
View Full Code Here

        return readEpub(resources, new Book());
    }
   
    public Book readEpub(Resources resources, Book result) throws IOException{
      if (result == null) {
        result = new Book();
      }
      handleMimeType(result, resources);
      String packageResourceHref = getPackageResourceHref(resources);
      Resource packageResource = processPackageResource(packageResourceHref, result, resources);
      result.setOpfResource(packageResource);
View Full Code Here

   * @param rootDirectory
   * @return the newly created Book
   * @throws IOException
   */
  public static Book createBookFromDirectory(FileObject rootDirectory, String encoding) throws IOException {
    Book result = new Book();
    List<TOCReference> sections = new ArrayList<TOCReference>();
    Resources resources = new Resources();
    processDirectory(rootDirectory, rootDirectory, sections, resources, encoding);
    result.setResources(resources);
    TableOfContents tableOfContents = new TableOfContents(sections);
    result.setTableOfContents(tableOfContents);
    result.setSpine(new Spine(tableOfContents));
   
    result = bookProcessor.processBook(result);
   
    return result;
  }
View Full Code Here

TOP

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

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.