1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

synchronization with native branch

This commit is contained in:
Nikolay Pultsin 2012-02-23 15:57:46 +01:00
parent 32215d6f85
commit 2032f9628b
2 changed files with 10 additions and 6 deletions

View file

@ -21,6 +21,7 @@ package org.geometerplus.fbreader.filetype;
import java.util.*;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.util.MimeType;
public class FileTypeCollection {
@ -49,4 +50,13 @@ public class FileTypeCollection {
public FileType typeById(String id) {
return myTypes.get(id.toLowerCase());
}
public FileType typeForFile(ZLFile file) {
for (FileType type : types()) {
if (type.acceptsFile(file)) {
return type;
}
}
return null;
}
}

View file

@ -24,14 +24,8 @@ import org.geometerplus.zlibrary.core.image.ZLImage;
import org.geometerplus.fbreader.bookmodel.BookModel;
import org.geometerplus.fbreader.library.Book;
import org.geometerplus.fbreader.filetype.*;
public abstract class FormatPlugin {
public final boolean acceptsFile(ZLFile file) {
final FileType fileType = FileTypeCollection.Instance.typeById(supportedFileType());
return fileType != null && fileType.acceptsFile(file);
}
public abstract String supportedFileType();
public abstract boolean readMetaInfo(Book book);
public abstract boolean readLanguageAndEncoding(Book book);