public URI toRemoteURI(final Book book) { try { return new URI(NetUtil.PROTOCOL_HTTP, host, packageDirectory + '/' + book.getInitials() + ZIP_SUFFIX, null); } catch (URISyntaxException e) { return null; } }
public int getPercentDone(Book document) { Integer percentDone = percentDoneByInitials.get(document.getInitials()); return percentDone!=null ? percentDone : 0; } }
public int compare(Book o1, Book o2) { return o1.getInitials().toUpperCase(Locale.ENGLISH).compareTo(o2.getInitials().toUpperCase(Locale.ENGLISH)); } };
public boolean checkCurrentDocumentStillInstalled() { if (currentDocument!=null) { Log.d(TAG, "checkCurrentDocumentStillInstalled:"+currentDocument); // this sets currentDoc to null if it does not exist currentDocument = swordDocumentFacade.getDocumentByInitials(currentDocument.getInitials()); } return currentDocument!=null; }
public void run() { Log.i(TAG, "Starting index download thread - book:"+book.getInitials()); downloadIndex(installer, book); } };
@Override public boolean test(Book book) { // just Calvin Commentaries for now to see how we go // // Cannot include Jasher, Jub, EEnochCharles because they are displayed as page per verse for some reason which looks awful. return super.test(book) && (book.getInitials().equals("CalvinCommentaries")); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((document == null) ? 0 : document.getInitials().hashCode()); result = prime * result + ((key == null) ? 0 : key.hashCode()); return result; }
/** a document has bad xml structure so record the fact so the default fault tolerant parser is used in the future * many books have extra tags in first and/or last chapters hence the graded level of failures */ public void failedToParse(Book document, Key key) { String initials = document.getInitials(); FailPosition documentFailPosition = failureInfoMap.get(initials); if (isStartOrEndOfBook(key)) { documentFailPosition = FailPosition.FIRST_AND_LAST_BOOK_CHAPTER; } else { documentFailPosition = FailPosition.ALL; } failureInfoMap.put(initials, documentFailPosition); }
/** * 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); } }
@Override protected void handleDocumentSelection(Book selectedBook) { Log.d(TAG, "Book selected:"+selectedBook.getInitials()); try { getDocumentControl().changeDocument(selectedBook); // if key is valid then the new doc will have been shown already returnToPreviousScreen(); } catch (Exception e) { Log.e(TAG, "error on select of bible book", e); } }
private void handleDownloadError(Book document) { ABEventBus.getDefault().post(new DocumentDownloadEvent(document.getInitials(), DocumentStatus.DocumentInstallStatus.ERROR_DOWNLOADING, 0)); downloadError.add(document.getInitials()); Dialogs.getInstance().showErrorMsg(R.string.error_downloading); }
/** * Download progress event */ public void onEventMainThread(DocumentDownloadEvent event) { if (document!=null && event.getInitials().equals(document.getInitials())) { updateControlState(event.getDocumentStatus()); } }
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()); }
/** called during app close down to save state */ @Override public JSONObject getStateJson() throws JSONException { JSONObject object = new JSONObject(); if (getCurrentDocument()!=null && getCurrentBibleVerse()!=null && getCurrentBibleVerse().getVerseSelected(getVersification())!=null) { Log.d(TAG, "Saving Commentary state for 1 window"); object.put("document", getCurrentDocument().getInitials()); // allow Bible page to save shared verse } return object; }
private Book getBook(String initials) { for (Book book : books) { if (book.getInitials().equals(initials)) { System.out.println("Found:"+book.getName()); return book; } } return null; }
/** called during app close down to save state */ @Override public JSONObject getStateJson() throws JSONException { JSONObject object = new JSONObject(); if (getCurrentDocument()!=null && getCurrentBibleVerse()!=null && getCurrentBibleVerse().getVerseSelected(getVersification())!=null) { Log.d(TAG, "Saving Bible state for 1 window"); object.put("document", getCurrentDocument().getInitials()); object.put("verse", getCurrentBibleVerse().getStateJson()); } return object; }
public void deleteDocumentIndex(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()); IndexManager imanager = IndexManagerFactory.getIndexManager(); if (imanager.isIndexed(realDocument)) { imanager.deleteIndex(realDocument); } }
public boolean isIndexDownloadAvailable(Book document) throws InstallException, BookException { // not sure how to integrate reuse this in JSword index download String version = document.getBookMetaData().getProperty("Version"); String versionSuffix = version!=null ? "-" + new Version(version).toString() : ""; String url = "http://www.crosswire.org/and-bible/indices/v1/"+document.getInitials()+versionSuffix+".zip"; return CommonUtils.isHttpUrlAvailable(url); }
@Override public void run() { log.info("Downloading index of " + document.getInitials() + " from AndBible repo"); try { final AndBibleRepo andBibleRepo = repoFactory.getAndBibleRepo(); andBibleRepo.downloadIndex(document); } catch (InstallException | BookException e) { Dialogs.getInstance().showErrorMsg(R.string.error_downloading); } } });
public void testReadLastChapter() throws Exception { for (Book book: books) { if (book.getBookCategory().equals(BookCategory.BIBLE)) { System.out.println("Book:"+book.getInitials()); OSISInputStream osisInputStream = new OSISInputStream(book, book.getKey("3 John")); 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)); } } }