/** * Get a particular installed book by initials. * * @param bookInitials * The book name to search for * @return The found book. Null otherwise. */ public Book getBook(String bookInitials) { return Books.installed().getBook(bookInitials); }
/** * 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()); }
/** * Get a particular installed book by initials. * * @param bookInitials * The book name to search for * @return The found book. Null otherwise. */ public static Book getInstalledBook(String bookInitials) { return Books.installed().getBook(bookInitials); }
/** * */ 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()); }
public Book getDocumentByInitials(String initials) { return Books.installed().getBook(initials); }
public Book getDefaultStrongsHebrewDictionary() { // default to StrongsRealHebrew or StrongsHebrew String[] preferredBooks = {"StrongsRealHebrew", "StrongsHebrew"}; for (String prefBook : preferredBooks) { Book strongs = Books.installed().getBook(prefBook); if (strongs!=null) { return strongs; } } return Defaults.getHebrewDefinitions(); }
/** prefer the Real alternatives to the default versions because they contain the native Greek Hebrew words */ public Book getDefaultStrongsGreekDictionary() { // default to StrongsRealGreek or StrongsGreek String[] preferredBooks = {"StrongsRealGreek", "StrongsGreek"}; for (String prefBook : preferredBooks) { Book strongs = Books.installed().getBook(prefBook); if (strongs!=null) { return strongs; } } return Defaults.getGreekDefinitions(); }
public @Nullable Book getSpeakBook() { if (playbackSettings != null && playbackSettings.getBookId() != null) { return Books.installed().getBook(playbackSettings.getBookId()); } else { return null; } }
/** * An example of how to search for various bits of data. * * @throws BookException */ public void search() throws BookException { Book bible = Books.installed().getBook(BIBLE_NAME); // This does a standard operator search. See the search documentation // for more examples of how to search Key key = bible.find("+moses +aaron"); System.out.println("The following verses contain both moses and aaron: " + key.getName()); // You can also trim the result to a more manageable quantity. // The test here is not necessary since we are working with a bible. It // is necessary if we don't know what it // is. if (key instanceof Passage) { Passage remaining = ((Passage) key).trimVerses(5); System.out.println("The first 5 verses containing both moses and aaron: " + key.getName()); if (remaining != null) { System.out.println("The rest of the verses are: " + remaining.getName()); } else { System.out.println("There are only 5 verses containing both moses and aaron"); } } }
Book b = Books.installed().getBook(args[0]); if (b == null) { System.err.println("Book not found");
Book b = Books.installed().getBook(args[0]); if (b == null) { System.err.println("Book not found");
public void dump(String name) throws BookException, IOException { Books books = Books.installed(); Book book = books.getBook(name); BookMetaData bmd = book.getBookMetaData(); StringBuffer buf = new StringBuffer();
@Before public void setup() { DocumentBibleBooksFactory mockDocumentBibleBooksFactory = mock(DocumentBibleBooksFactory.class); bibleTraverser = new BibleTraverser(mockDocumentBibleBooksFactory); testBook = (AbstractPassageBook) Books.installed().getBook("ESV2011"); }
/** * Install a book, overwriting it if the book to be installed is newer. * * @param repositoryName * the name of the repository from which to get the book * @param book * the book to get * @throws BookException * @throws InstallException */ public void installBook(String repositoryName, Book book) throws BookException, InstallException { // An installer knows how to install books Installer installer = installManager.getInstaller(repositoryName); // Delete the book, if present // At the moment, JSword will not re-install. Later it will, if the // remote version is greater. if (Books.installed().getBook(book.getInitials()) != null) { deleteBook(book); } // Now install it. Note this is a background task. installer.install(book); }
@Before public void setup() { documentBibleBooksFactory = new DocumentBibleBooksFactory(); esv = (AbstractPassageBook) Books.installed().getBook("ESV2011"); }
/** * An example of how to do a search and then get text for each range of * verses. * * @throws BookException * @throws SAXException */ void searchAndShow() throws BookException, SAXException { Book bible = Books.installed().getBook(BIBLE_NAME); // Search for words like Melchezedik Key key = bible.find("melchesidec~"); // Here is an example of how to iterate over the ranges and get the text // for each. // The key's iterator would have iterated over verses. // The following shows how to use a stylesheet of your own choosing String path = "org/crosswire/jsword/xml/html5.xsl"; URL xslurl = ResourceUtil.getResource(path); // Make ranges break on chapter Iterator<VerseRange> rangeIter = ((Passage) key).rangeIterator(RestrictionType.CHAPTER); // boundaries. while (rangeIter.hasNext()) { Key range = rangeIter.next(); BookData data = new BookData(bible, range); SAXEventProvider osissep = data.getSAXEventProvider(); SAXEventProvider htmlsep = new TransformingSAXEventProvider(NetUtil.toURI(xslurl), osissep); String text = XMLUtil.writeToString(htmlsep); System.out.println("The html text of " + range.getName() + " is " + text); } }
Book bible = Books.installed().getBook(BIBLE_NAME);
@Test public void testContains() { AbstractPassageBook esv = (AbstractPassageBook)Books.installed().getBook("ESV2011"); DocumentBibleBooks esvBibleBooks = new DocumentBibleBooks(esv); assertThat(true, is(esvBibleBooks.contains(BibleBook.GEN))); assertThat(true, is(esvBibleBooks.contains(BibleBook.OBAD))); assertThat(false, is(esvBibleBooks.contains(BibleBook.PR_AZAR))); } }
if (book==null || key==null) { retVal = ""; } else if (Books.installed().getBook(book.getInitials())==null) { Log.w(TAG, "Book may have been uninstalled:"+book); String errorMsg = BibleApplication.Companion.getApplication().getString(R.string.document_not_installed, book.getInitials());
Book installedBook = Books.installed().getBook(bookInitials); if (installedBook!= null) {