示例#1
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);
    }
  }
示例#2
0
 public Collection<FsBook> getBooks(FsModule module) {
   return context.getBookList(module.Books == context.bookSet ? context.bookSet : null);
 }