public List<String> titlesForTitlePrefix(String prefix, int limit) { if (limit <= 0) { return Collections.emptyList(); } final ArrayList<String> titles = new ArrayList<String>(limit); synchronized (myBooksByFile) { for (Book b : myBooksByFile.values()) { if (prefix.equals(TitleUtil.firstTitleLetter(b))) { titles.add(b.getTitle()); if (--limit == 0) { break; } } } } return titles; }
public List<String> titlesForTag(Tag tag, int limit) { if (limit <= 0) { return Collections.emptyList(); } final ArrayList<String> titles = new ArrayList<String>(limit); final boolean isNull = Tag.NULL.equals(tag); synchronized (myBooksByFile) { for (Book b : myBooksByFile.values()) { if (isNull ? b.tags().isEmpty() : b.tags().contains(tag)) { titles.add(b.getTitle()); if (--limit == 0) { break; } } } } return titles; }
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; }
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; }