예제 #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();
 }