Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.Book.addSection()


public class SearchIndexTest extends TestCase {

  public void testDoSearch1() {
    try {
      Book testBook = new Book();
      testBook.addSection("chapter1", new Resource(new StringReader("a"), "chapter1.html"));
      testBook.addSection("chapter2", new Resource(new StringReader("<title>ab</title>"), "chapter2.html"));
      testBook.addSection("chapter3", new Resource(new StringReader("ba"), "chapter3.html"));
      testBook.addSection("chapter4", new Resource(new StringReader("aa"), "chapter4.html"));
      SearchIndex searchIndex = new SearchIndex(testBook);
      SearchResults searchResults = searchIndex.doSearch("a");
View Full Code Here


  public void testDoSearch1() {
    try {
      Book testBook = new Book();
      testBook.addSection("chapter1", new Resource(new StringReader("a"), "chapter1.html"));
      testBook.addSection("chapter2", new Resource(new StringReader("<title>ab</title>"), "chapter2.html"));
      testBook.addSection("chapter3", new Resource(new StringReader("ba"), "chapter3.html"));
      testBook.addSection("chapter4", new Resource(new StringReader("aa"), "chapter4.html"));
      SearchIndex searchIndex = new SearchIndex(testBook);
      SearchResults searchResults = searchIndex.doSearch("a");
      assertFalse(searchResults.isEmpty());
View Full Code Here

  public void testDoSearch1() {
    try {
      Book testBook = new Book();
      testBook.addSection("chapter1", new Resource(new StringReader("a"), "chapter1.html"));
      testBook.addSection("chapter2", new Resource(new StringReader("<title>ab</title>"), "chapter2.html"));
      testBook.addSection("chapter3", new Resource(new StringReader("ba"), "chapter3.html"));
      testBook.addSection("chapter4", new Resource(new StringReader("aa"), "chapter4.html"));
      SearchIndex searchIndex = new SearchIndex(testBook);
      SearchResults searchResults = searchIndex.doSearch("a");
      assertFalse(searchResults.isEmpty());
      assertEquals(5, searchResults.size());
View Full Code Here

    try {
      Book testBook = new Book();
      testBook.addSection("chapter1", new Resource(new StringReader("a"), "chapter1.html"));
      testBook.addSection("chapter2", new Resource(new StringReader("<title>ab</title>"), "chapter2.html"));
      testBook.addSection("chapter3", new Resource(new StringReader("ba"), "chapter3.html"));
      testBook.addSection("chapter4", new Resource(new StringReader("aa"), "chapter4.html"));
      SearchIndex searchIndex = new SearchIndex(testBook);
      SearchResults searchResults = searchIndex.doSearch("a");
      assertFalse(searchResults.isEmpty());
      assertEquals(5, searchResults.size());
      assertEquals(0, searchResults.getHits().get(0).getPagePos());
View Full Code Here

            // Set cover image
            book.setCoverImage(new Resource(Simple1.class.getResourceAsStream("/book1/test_cover.png"), "cover.png"));

            // Add Chapter 1
            book.addSection("Introduction", new Resource(Simple1.class.getResourceAsStream("/book1/chapter1.html"), "chapter1.html"));

            // Add css file
            book.getResources().add(new Resource(Simple1.class.getResourceAsStream("/book1/book1.css"), "book1.css"));

            // Add Chapter 2
View Full Code Here

            // Add css file
            book.getResources().add(new Resource(Simple1.class.getResourceAsStream("/book1/book1.css"), "book1.css"));

            // Add Chapter 2
            TOCReference chapter2 = book.addSection("Second Chapter", new Resource(Simple1.class.getResourceAsStream("/book1/chapter2.html"), "chapter2.html"));

            // Add image used by Chapter 2
            book.getResources().add(new Resource(Simple1.class.getResourceAsStream("/book1/flowers_320x240.jpg"), "flowers.jpg"));

            // Add Chapter2, Section 1
View Full Code Here

            // Add image used by Chapter 2
            book.getResources().add(new Resource(Simple1.class.getResourceAsStream("/book1/flowers_320x240.jpg"), "flowers.jpg"));

            // Add Chapter2, Section 1
            book.addSection(chapter2, "Chapter 2, section 1", new Resource(Simple1.class.getResourceAsStream("/book1/chapter2_1.html"), "chapter2_1.html"));

            // Add Chapter 3
            book.addSection("Conclusion", new Resource(Simple1.class.getResourceAsStream("/book1/chapter3.html"), "chapter3.html"));

            // Create EpubWriter
View Full Code Here

            // Add Chapter2, Section 1
            book.addSection(chapter2, "Chapter 2, section 1", new Resource(Simple1.class.getResourceAsStream("/book1/chapter2_1.html"), "chapter2_1.html"));

            // Add Chapter 3
            book.addSection("Conclusion", new Resource(Simple1.class.getResourceAsStream("/book1/chapter3.html"), "chapter3.html"));

            // Create EpubWriter
            EpubWriter epubWriter = new EpubWriter();

            // Write the Book as Epub
View Full Code Here

      book.getMetadata().addAuthor(new Author("Joe", "Tester"));
      InputStream is = this.getClass().getResourceAsStream("/book1/cover.png");
      book.setCoverImage(new Resource(is, "cover.png"));
      // Add Chapter 1
      InputStream is1 = this.getClass().getResourceAsStream("/book1/chapter1.html");
      book.addSection("Introduction", new Resource(is1, "chapter1.html"));
 
      EpubWriter epubWriter = new EpubWriter();
      epubWriter.write(book, new FileOutputStream("test1_book1.epub"));
  }
 
View Full Code Here

   
    book.getMetadata().addIdentifier(new Identifier(Identifier.Scheme.ISBN, "987654321"));
    book.getMetadata().addAuthor(new Author("Joe", "Tester"));
    book.setCoverPage(new Resource(this.getClass().getResourceAsStream("/book1/cover.html"), "cover.html"));
    book.setCoverImage(new Resource(this.getClass().getResourceAsStream("/book1/cover.png"), "cover.png"));
    book.addSection("Chapter 1", new Resource(this.getClass().getResourceAsStream("/book1/chapter1.html"), "chapter1.html"));
    book.addResource(new Resource(this.getClass().getResourceAsStream("/book1/book1.css"), "book1.css"));
    TOCReference chapter2 = book.addSection("Second chapter", new Resource(this.getClass().getResourceAsStream("/book1/chapter2.html"), "chapter2.html"));
    book.addResource(new Resource(this.getClass().getResourceAsStream("/book1/flowers_320x240.jpg"), "flowers.jpg"));
    book.addSection(chapter2, "Chapter 2 section 1", new Resource(this.getClass().getResourceAsStream("/book1/chapter2_1.html"), "chapter2_1.html"));
    book.addSection("Chapter 3", new Resource(this.getClass().getResourceAsStream("/book1/chapter3.html"), "chapter3.html"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.