Esempio n. 1
0
  boolean readMetaInfo() {
    myEncoding = null;
    myLanguage = null;
    myTitle = null;
    myAuthors = null;
    myTags = null;
    mySeriesInfo = null;

    myIsSaved = false;

    final FormatPlugin plugin = PluginCollection.Instance().getPlugin(File);
    if (plugin == null || !plugin.readMetaInfo(this)) {
      return false;
    }
    if (myTitle == null || myTitle.length() == 0) {
      final String fileName = File.getShortName();
      final int index = fileName.lastIndexOf('.');
      setTitle(index > 0 ? fileName.substring(0, index) : fileName);
    }
    final String demoPathPrefix =
        Paths.BooksDirectoryOption().getValue()
            + java.io.File.separator
            + "Demos"
            + java.io.File.separator;
    if (File.getPath().startsWith(demoPathPrefix)) {
      final String demoTag = LibraryUtil.resource().getResource("demo").getValue();
      setTitle(getTitle() + " (" + demoTag + ")");
      addTag(demoTag);
    }
    return true;
  }
  public Book getBookByFile(ZLFile bookFile) {
    if (bookFile == null) {
      return null;
    }
    final FormatPlugin plugin = PluginCollection.Instance().getPlugin(bookFile);
    if (plugin == null) {
      return null;
    }
    try {
      bookFile = plugin.realBookFile(bookFile);
    } catch (BookReadingException e) {
      return null;
    }

    Book book = myBooksByFile.get(bookFile);
    if (book != null) {
      return book;
    }

    final ZLPhysicalFile physicalFile = bookFile.getPhysicalFile();
    if (physicalFile != null && !physicalFile.exists()) {
      return null;
    }

    final FileInfoSet fileInfos = new FileInfoSet(myDatabase, bookFile);

    book = myDatabase.loadBookByFile(fileInfos.getId(bookFile), bookFile);
    if (book != null) {
      book.loadLists(myDatabase);
    }

    if (book != null && fileInfos.check(physicalFile, physicalFile != bookFile)) {
      saveBook(book, false);
      // saved
      addBook(book, false);
      return book;
    }
    fileInfos.save();

    try {
      if (book == null) {
        book = new Book(bookFile);
      } else {
        book.readMetaInfo();
      }
    } catch (BookReadingException e) {
      return null;
    }

    saveBook(book, false);
    return book;
  }
Esempio n. 3
0
 synchronized ZLImage getCover() {
   if (myCover == NULL_IMAGE) {
     return null;
   } else if (myCover != null) {
     final ZLImage image = myCover.get();
     if (image != null) {
       return image;
     }
   }
   ZLImage image = null;
   final FormatPlugin plugin = PluginCollection.Instance().getPlugin(File);
   if (plugin != null) {
     image = plugin.readCover(File);
   }
   myCover = image != null ? new WeakReference<ZLImage>(image) : NULL_IMAGE;
   return image;
 }