(String filename)
| 568 | } |
| 569 | |
| 570 | public static Book open(String filename) |
| 571 | throws IOException, BookException { |
| 572 | |
| 573 | String filenameLowerCase = filename.toLowerCase(); |
| 574 | |
| 575 | if (filenameLowerCase.endsWith(EPUB_EXTENSION)) { |
| 576 | return new EPubBook(filename); |
| 577 | } |
| 578 | |
| 579 | if (filenameLowerCase.endsWith(PLAIN_TEXT_EXTENSION)) { |
| 580 | return new FileBook(filename, null, new PlainTextParser(), false); |
| 581 | } |
| 582 | |
| 583 | if (filenameLowerCase.endsWith(HTM_EXTENSION) |
| 584 | || filenameLowerCase.endsWith(HTML_EXTENSION) |
| 585 | || filenameLowerCase.endsWith(XHTML_EXTENSION)) { |
| 586 | return new FileBook( |
| 587 | filename, |
| 588 | new ArchiveFolder( |
| 589 | RandomReadingFile.getPathFromURL(filename)), |
| 590 | new HTMLTextParser(), |
| 591 | true); |
| 592 | } |
| 593 | |
| 594 | throw new BookException("Unsupported file format."); |
| 595 | } |
| 596 | |
| 597 | protected final void linkChapters() { |
| 598 | Chapter prev; |
no test coverage detected