/** ensure a book is indexed and the index contains typical Greek or Hebrew Strongs Numbers */ private boolean checkStrongs(Book bible) { try { return bible.getIndexStatus().equals(IndexStatus.DONE) && (bible.find("+[Gen 1:1] strong:h7225").getCardinality()>0 || bible.find("+[John 1:1] strong:g746").getCardinality()>0 || bible.find("+[Gen 1:1] strong:g746").getCardinality()>0); } catch (BookException be) { Log.e(TAG, "Error checking strongs numbers", be); return false; } }
/** * Read all the books that we can get our hands on. * @param args */ public static void main(String[] args) { // TODO(DMS): add the ability to pass a filter specification // Loop through all the Books log.warn("*** Reading all installed Bibles"); BookFilter filter = null; //filter = BookFilters.getCustom("SourceType=ThML"); //filter = BookFilters.getCustom("Description=Ergane Turkish to English Glossary"); //filter = BookFilters.getCustom("ModDrv=zLD"); //filter = BookFilters.getCustom("Initials=BosworthToller"); //filter = BookFilters.getDictionaries(); List<Book> books = getBooks(filter); for (Book book : books) { if (book.isLocked()) { log.warn("****** Skipping: [{}] {} ({})", book.getInitials(), book.getName(), book.getBookCategory()); continue; } log.warn("****** Reading: [{}] {} ({})", book.getInitials(), book.getName(), book.getBookCategory()); Key set = book.getGlobalKeyList(); testReadMultiple(book, set); } }
public void setKey(String keyText) { Log.d(TAG, "key text:"+keyText); try { Key key = getCurrentDocument().getKey(keyText); setKey(key); } catch (NoSuchKeyException nske) { Log.e(TAG, "Invalid verse reference:"+keyText); } }
public boolean test(Book book) { return book.hasFeature(feature) && !book.isLocked(); }
@Override public boolean equals(Object obj) { // The real bit ... Book thatBook = ((BookKey)obj).book; return book.getBookCategory().equals(thatBook.getBookCategory()) && book.getAbbreviation().equals(thatBook.getAbbreviation()) && book.getLanguage().equals(thatBook.getLanguage()); }
@Override public boolean test(Book book) { return book.getBookCategory().equals(bookCategory) && !book.isLocked(); } });
private OsisToHtmlSaxHandler getSaxHandler(Book book, Key key, boolean asFragment) { OsisToHtmlParameters osisToHtmlParameters = new OsisToHtmlParameters(); BookCategory bookCategory = book.getBookCategory(); BookMetaData bmd = book.getBookMetaData(); osisToHtmlParameters.setLanguageCode(book.getLanguage().getCode()); osisToHtmlParameters.setModuleBasePath(book.getBookMetaData().getLocation()); osisToHtmlParameters.setAutoWrapUnwrappedRefsInNote("HunUj".equals(book.getInitials())); if (book.hasFeature(FeatureType.HEBREW_DEFINITIONS)) { } else if (book.hasFeature(FeatureType.GREEK_DEFINITIONS)) {
@Test public void testReadCommentaries() throws Exception { for (Book book: books) { if (book.getBookCategory().equals(BookCategory.COMMENTARY) && !book.getInitials().equals("Personal")) { // if (book.getInitials().equals("JFB")) { System.out.println("Book:"+book.getInitials()); OSISInputStream osisInputStream = new OSISInputStream(book, book.getKey("John 1:1")); String chapter = convertStreamToString(osisInputStream); int numOpeningDivs = count(chapter, "<div>"); int numClosingDivs = count(chapter, "</div>"); System.out.println(chapter); assertThat("wrong number of divs in "+book, numOpeningDivs, equalTo(numClosingDivs)); } } }
/** * Add a Book to the current list of Books. This method should only be * called by BibleDrivers, it is not a method for general consumption. * * @param book the book to add to this book list */ public synchronized void addBook(Book book) { if (book != null && books.add(book)) { initials.put(book.getInitials(), book); names.put(book.getName(), book); fireBooksChanged(instance, book, true); } }
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()); } } }
public int getPercentDone(Book document) { Integer percentDone = percentDoneByInitials.get(document.getInitials()); return percentDone!=null ? percentDone : 0; } }
/** * This method is identical to <code>getDefault().getName()</code> and is * only used by Config which works best with strings under reflection. * * @return the default book name */ public String getDefaultName() { if (book == null) { return null; } return book.getName(); }
public void mod2imp() throws BookException { // Use short key names for Bibles. if (BookCategory.BIBLE.equals(book.getBookCategory())) { BookName.setFullBookName(false); } Key keys = book.getGlobalKeyList(); StringBuilder buf = new StringBuilder(); for (Key key : keys) { //FIXME(CJB) iteration should be pushed down to benefit from performance improvement String rawText = book.getRawText(key); if (rawText != null && rawText.trim().length() > 0) { buf.delete(0, buf.length()); buf.append("$$$").append(key).append('\n').append(rawText); System.out.println(buf.toString()); } } }
public boolean test(Book book) { String property = book.getProperty(key); return property != null && property.equals(value); }
if (BookCategory.BIBLE.equals(book.getBookCategory())) { key = book.getKey(reference); ((Passage) key).trimVerses(maxKeyCount); } else { key = book.createEmptyKeyList(); for (Key aKey : book.getKey(reference)) { if (++count >= maxKeyCount) { break;
public boolean test(Book book) { for (int i = 0; i < tests.length; i++) { Test test = tests[i]; if ("initials".equalsIgnoreCase(test.property)) { if (!test.result.equals(book.getInitials())) { return false; } continue; } String result = book.getProperty(test.property); if (result == null || !test.result.equals(result)) { return false; } } return true; }
@Override public boolean equals(Object obj) { // Since this can not be null if (obj == null) { return false; } // We might consider checking for equality against all Books? // However currently we don't. // Check that that is the same as this // Don't use instanceof since that breaks inheritance if (!obj.getClass().equals(this.getClass())) { return false; } // The real bit ... Book that = (Book) obj; return bmd.equals(that.getBookMetaData()); }
public static void report(Book b) { if (!b.getBookCategory().equals(BookCategory.BIBLE) && !b.getBookCategory().equals(BookCategory.COMMENTARY)) { System.err.println(b.getInitials() + " is not a Bible or Commentary"); // System.exit(1); } BibleScope scope = new BibleScope(b); BookName.setFullBookName(false); // use short names System.out.println('[' + b.getInitials() + ']'); System.out.println("InScope=" + scope.getInScope().getOsisRef()); System.out.println("OutScope=" + scope.getOutOfScope().getOsisRef()); }
public void deleteDocument(Book document) throws BookException { // make sure we have the correct Book and not just a copy e.g. one from a Download Manager Book realDocument = getDocumentByInitials(document.getInitials()); // delete index first if it exists but wrap in try to ensure an attempt is made to delete the document try { IndexManager imanager = IndexManagerFactory.getIndexManager(); if (imanager.isIndexed(realDocument)) { imanager.deleteIndex(realDocument); } } catch (Exception e) { // just log index delete error, deleting doc is the important thing log.error("Error deleting document index", e); } document.getDriver().delete(realDocument); }
@Override public void restoreState(JSONObject jsonObject) throws JSONException { if (jsonObject!=null) { Log.d(TAG, "Restoring page state"); if (jsonObject.has("document")) { String document = jsonObject.getString("document"); if (StringUtils.isNotEmpty(document)) { Log.d(TAG, "State document:"+document); Book book = swordDocumentFacade.getDocumentByInitials(document); if (book!=null) { Log.d(TAG, "Restored document:"+book.getName()); // bypass setter to avoid automatic notifications localSetCurrentDocument(book); try { if (jsonObject.has("key")) { String keyName = jsonObject.getString("key"); if (StringUtils.isNotEmpty(keyName)) { doSetKey(book.getKey(keyName)); Log.d(TAG, "Restored key:"+keyName); } } } catch (Exception e) { Log.e(TAG, "Error restoring key for document category:"+getBookCategory().getName()); } } } } } }