/** * Get a list of installed books by BookFilter. * * @param filter * The book filter * @return the list of matching books * @see BookFilter * @see Books */ public static List<Book> getInstalledBooks(BookFilter filter) { return Books.installed().getBooks(filter); }
/** * Get a list of all installed books. * * @return the list of installed books */ public static List<Book> getInstalledBooks() { return Books.installed().getBooks(); }
public List<Language> sortLanguages(Collection<Language> languages) { List<Language> languageList = new ArrayList<>(); if (languages!=null) { languageList.addAll(languages); // sort languages alphabetically Collections.sort(languageList, new RelevantLanguageSorter(Books.installed().getBooks())); } return languageList; }
/** * List the available versions */ private static void versions() { System.out.println(" Available versions:"); List<Book> lbmds = Books.installed().getBooks(); for (Book book : lbmds) { System.out.println(" " + book.getName()); } } }
/** * Go through all of the current books checking to see if we need to replace * the current defaults with one of these. */ protected static void checkAllPreferable() { for (Book book : Books.installed().getBooks()) { checkPreferable(book); } }
/** * Convert a filter into an array of names of Books that pass the filter. * * @param filter the filter to locate matching books * @return matching books */ private static Map<Book, String> getBookMap(BookFilter filter) { Map<Book, String> books = new TreeMap<Book, String>(BookComparators.getDefault()); for (Book book : Books.installed().getBooks(filter)) { books.put(book, book.getName()); } return books; }
/** return all supported documents - bibles and commentaries for now */ public List<Book> getDocuments() { log.debug("Getting books"); // currently only bibles and commentaries are supported List<Book> allDocuments = Books.installed().getBooks(SUPPORTED_DOCUMENT_TYPES); log.debug("Got books, Num="+allDocuments.size()); return allDocuments; }
public static String generateInstalledBooksIndexVersionReport(BookFilter filter) { StringBuilder toReturn = new StringBuilder(); int installedBookCount = 0; int searchEnabledBookCount = 0; int reindexMandatoryBookCount = 0; LuceneIndexManager indexManager = (LuceneIndexManager) IndexManagerFactory.getIndexManager(); Books myBooks = Books.installed(); toReturn.append("InstalledBooks:"); for (Book insBook : myBooks.getBooks(filter)) { installedBookCount++; toReturn.append("\n\t").append(insBook.getBookMetaData().getInitials()).append(": "); if (indexManager.isIndexed(insBook)) { searchEnabledBookCount++; toReturn.append("search enabled, "); if (indexManager.needsReindexing(insBook)) { reindexMandatoryBookCount++; toReturn.append("index outdated, "); } } } toReturn.append("\nSummary: installedBooks ").append(installedBookCount).append(", searchEnabledBooks ").append(searchEnabledBookCount) .append(", booksWithOutdatedIndex ").append(reindexMandatoryBookCount).append("\n"); return toReturn.toString(); }
public List<Book> getBibles() { log.debug("Getting bibles"); List<Book> documents = Books.installed().getBooks(BookFilters.getBibles()); log.debug("Got bibles, Num="+documents.size()); return documents; }
public List<Book> getBooks(final BookCategory bookCategory) { log.debug("Getting books of type "+bookCategory.getName()); List<Book> documents = Books.installed().getBooks(new BookFilter() { @Override public boolean test(Book book) { return book.getBookCategory().equals(bookCategory) && !book.isLocked(); } }); log.debug("Got books, Num="+documents.size()); return documents; }
/** * Read all the books that we can get our hands on. * * @param args * @throws IOException */ public static void main(String[] args) throws IOException { out = new PrintWriter(new BufferedWriter(new FileWriter("passages.log"))); // Loop through all the Books log.warn("*** Reading all known Books"); BookFilter filter = BookFilters.getCustom("GlobalOptionFilter=ThMLScripref;Category=Biblical Texts"); List<Book> comments = Books.installed().getBooks(filter); for (Book book : comments) { if (!book.isLocked()) { BookMetaData bmd = book.getBookMetaData(); // Skip PlainText as they do not have references marked up if (bmd.getProperty("SourceType") != null) { Key set = book.getGlobalKeyList(); readBook(book, set); } } } out.flush(); out.close(); }
/** * This is an example of the different ways to select a Book from the * selection available. * * @see org.crosswire.common.config.Config * @see Books */ public void pickBible() { // The Default Bible - JSword does everything it can to make this work Book book = Books.installed().getBook(BIBLE_NAME); // And you can find out more too: System.out.println(book.getLanguage()); // If you want a greater selection of Books: List<Book> books = Books.installed().getBooks(); book = books.get(0); // Or you can narrow the range a bit books = Books.installed().getBooks(BookFilters.getOnlyBibles()); book = books.get(0); // There are implementations of BookFilter for all sorts of things in // the BookFilters class // If you are wanting to get really fancy you can implement your own // BookFilter easily List<Book> test = Books.installed().getBooks(new MyBookFilter("ESV")); book = test.get(0); if (book != null) { System.out.println(book.getInitials()); } // If you want to know about new books as they arrive: Books.installed().addBooksListener(new MyBooksListener()); }
/** * While Bible and Commentary are very similar, a Dictionary is read in a * slightly different way. It is also worth looking at the JavaDoc for Book * that has a way of treating Bible, Commentary and Dictionary the same. * * @throws BookException * @see Book */ public void readDictionary() throws BookException { // This just gets a list of all the known dictionaries and picks the // first. In a real world app you will probably have a better way // of doing this. List<Book> dicts = Books.installed().getBooks(BookFilters.getDictionaries()); Book dict = dicts.get(0); // If I want every key in the Dictionary then I do this (or something // like it - in the real world you want to call hasNext() on an iterator // before next() but the point is the same: Key keys = dict.getGlobalKeyList(); Key first = keys.iterator().next(); System.out.println("The first Key in the default dictionary is " + first); BookData data = new BookData(dict, first); System.out.println("And the text against that key is " + OSISUtil.getPlainText(data.getOsisFragment())); }
/** * */ public StrongsAnalysis() { Book bible = Books.installed().getBook("KJV"); if (!bible.hasFeature(FeatureType.STRONGS_NUMBERS)) { bible = null; List<Book> bibles = Books.installed().getBooks(new BookFilters.BookFeatureFilter(FeatureType.STRONGS_NUMBERS)); if (!bibles.isEmpty()) { bible = bibles.get(0); } } if (bible == null) { return; } List<Key> errors = new ArrayList<Key>(); StrongsMapSet sms = new StrongsMapSet(); analyze(sms, bible, errors, bible.getGlobalKeyList()); }
/** * Basic constructor * @param args */ public static void main(String[] args) { Book version = null; if (args.length == 0) { usage(); versions(); //System.exit(1); } List<Book> dicts = Books.installed().getBooks(BookFilters.getOnlyBibles()); version = dicts.get(0); Speed speed = new Speed(version); speed.run(); double time = speed.getBenchmark() / 1000.0; System.out.println("CBench mark for '" + version + "': " + time + "s"); }
public void testFindAllStrongsRef() { List<Book> bibles = Books.installed().getBooks(BookFilters.getBibles()); for (Book book : bibles) { try { if (book.hasFeature(FeatureType.STRONGS_NUMBERS)) { if (!book.getIndexStatus().equals(IndexStatus.DONE)) { System.out.println("Unindexed:"+book); } else { Key resultsH = book.find("+[Gen 1:1] strong:h7225"); //beginning Key resultsG = book.find("+[John 1:1] strong:g746"); //beginning Key resultsGOT = book.find("+[Gen 1:1] strong:g746"); //beginning if (resultsH.getCardinality()==0 && resultsG.getCardinality()==0 && resultsGOT.getCardinality()==0) { System.out.println("No refs returned in"+book.getInitials()); } else { System.out.println("Ok:"+book.getInitials()+" "+resultsH.getCardinality()+"/"+resultsG.getCardinality()+ "/" + resultsGOT.getCardinality()); } // assertTrue("No refs returned in"+book.getInitials(), resultsH.getCardinality()>0 || resultsG.getCardinality()>0); } } } catch (Exception e) { System.out.println("Error:"+book.getInitials()+":"+e.getMessage()); } } }