diff --git a/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java b/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java index 752cc30..ea0bc0a 100644 --- a/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java +++ b/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java @@ -4,7 +4,9 @@ import org.crosswire.jsword.book.BookCategory; import org.crosswire.jsword.book.BookFilter; import org.crosswire.jsword.book.BookFilters; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; /** * Module to help with some conversions between BookCategories and BookFilters @@ -43,6 +45,16 @@ public class FilterUtil { } } + public static List applyFilter(List books, BookFilter f) { + List filtered = new ArrayList(); + for (Book b: books) { + if (f.test(b)) { + filtered.add(f); + } + } + return filtered; + } + public static class InvalidFilterCategoryMappingException extends Exception { public InvalidFilterCategoryMappingException(String message) { super(message);