Пример #1
0
  public LinkedHashMap<String, String> searchInBook(FsModule module, String bookID, String regQuery)
      throws BookNotFoundException {
    LinkedHashMap<String, String> searchRes = null;

    FsBook book = getBookByID(module, bookID);
    if (book == null) {
      throw new BookNotFoundException(module.getID(), bookID);
    }

    BufferedReader bReader = null;
    try {
      bReader = context.getBookReader(book);
      searchRes = context.searchInBook(module, bookID, regQuery, bReader);
    } catch (FileAccessException e) {
      throw new BookNotFoundException(module.getID(), bookID);

    } finally {
      try {
        if (bReader != null) {
          bReader.close();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return searchRes;
  }
Пример #2
0
  public Collection<FsBook> loadBooks(FsModule module)
      throws OpenModuleException, BooksDefinitionException, BookDefinitionException {

    synchronized (context.bookSet) {
      if (module.Books != context.bookSet) {

        module.Books = context.bookSet = new LinkedHashMap<String, Book>();
        BufferedReader reader = null;
        String moduleID = "";
        String moduleDatasourceID = "";
        try {
          moduleID = module.getID();
          moduleDatasourceID = module.getDataSourceID();
          reader = context.getModuleReader(module);
          context.fillBooks(module, reader);

        } catch (FileAccessException e) {
          // Lod.e(TAG, String.format("Can't load books from module
          // (%1$s, %2$s)", moduleID, moduleDatasourceID));
          throw new OpenModuleException(moduleID, moduleDatasourceID);

        } finally {
          try {
            if (reader != null) {
              reader.close();
            }
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
      return context.getBookList(context.bookSet);
    }
  }
Пример #3
0
 public Collection<FsBook> getBooks(FsModule module) {
   return context.getBookList(module.Books == context.bookSet ? context.bookSet : null);
 }
Пример #4
0
 public FsBookRepository(FsLibraryContext context) {
   this.context = context;
   this.cache = context.getCache();
 }