Exemplo n.º 1
0
 public boolean hasSeries() {
   synchronized (myBooksByFile) {
     for (Book book : myBooksByFile.values()) {
       if (book.getSeriesInfo() != null) {
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 2
0
 public List<Book> booksForSeries(String series) {
   final LinkedList<Book> filtered = new LinkedList<Book>();
   for (Book b : books()) {
     final SeriesInfo info = b.getSeriesInfo();
     if (info != null && series.equals(info.Title)) {
       filtered.add(b);
     }
   }
   return filtered;
 }
Exemplo n.º 3
0
 public List<String> series() {
   final Set<String> series = new TreeSet<String>();
   synchronized (myBooksByFile) {
     for (Book book : myBooksByFile.values()) {
       final SeriesInfo info = book.getSeriesInfo();
       if (info != null) {
         series.add(info.Title);
       }
     }
   }
   return new ArrayList<String>(series);
 }
Exemplo n.º 4
0
 public List<Book> booksForSeriesAndAuthor(String series, Author author) {
   final boolean isNull = Author.NULL.equals(author);
   final LinkedList<Book> filtered = new LinkedList<Book>();
   for (Book b : books()) {
     final List<Author> bookAuthors = b.authors();
     final SeriesInfo info = b.getSeriesInfo();
     if (info != null
         && series.equals(info.Title)
         && (isNull && bookAuthors.isEmpty() || bookAuthors.contains(author))) {
       filtered.add(b);
     }
   }
   return filtered;
 }
Exemplo n.º 5
0
 public List<String> titlesForSeries(String series, int limit) {
   if (limit <= 0) {
     return Collections.emptyList();
   }
   final ArrayList<String> titles = new ArrayList<String>(limit);
   synchronized (myBooksByFile) {
     for (Book b : myBooksByFile.values()) {
       final SeriesInfo info = b.getSeriesInfo();
       if (info != null && series.equals(info.Title)) {
         titles.add(b.getTitle());
         if (--limit == 0) {
           break;
         }
       }
     }
   }
   return titles;
 }
Exemplo n.º 6
0
 public List<String> titlesForSeriesAndAuthor(String series, Author author, int limit) {
   if (limit <= 0) {
     return Collections.emptyList();
   }
   final boolean isNull = Author.NULL.equals(author);
   final ArrayList<String> titles = new ArrayList<String>(limit);
   synchronized (myBooksByFile) {
     for (Book b : myBooksByFile.values()) {
       final List<Author> bookAuthors = b.authors();
       final SeriesInfo info = b.getSeriesInfo();
       if (info != null
           && series.equals(info.Title)
           && (isNull && bookAuthors.isEmpty() || bookAuthors.contains(author))) {
         titles.add(b.getTitle());
         if (--limit == 0) {
           break;
         }
       }
     }
   }
   return titles;
 }