/** * 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(); }
protected void manageDownload(final Book documentToDownload) { if (documentToDownload!=null) { new AlertDialog.Builder(this) .setMessage(getText(R.string.download_document_confirm_prefix) + " " + documentToDownload.getName()) .setCancelable(false) .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { doDownload(documentToDownload); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }).create().show(); } }
protected void handleDeleteIndex(final List<Book> documents) { for (final Book document : documents) { CharSequence msg = getString(R.string.delete_search_index_doc, document.getName()); new AlertDialog.Builder(this) .setMessage(msg).setCancelable(true) .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { try { Log.d(TAG, "Deleting index:" + document); getSwordDocumentFacade().deleteDocumentIndex(document); } catch (Exception e) { Dialogs.getInstance().showErrorMsg(R.string.error_occurred, e); } } } ) .create() .show(); } }
/** * 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()); } } }
/** * 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); } }
/** * Search for the book by initials and name. * Looks for exact matches first, then searches case insensitive. * In all cases the whole initials or the whole name has to match. * * @param name The initials or name of the book to find * @return the book or null */ public synchronized Book getBook(String name) { if (name == null) { return null; } Book book = initials.get(name); if (book != null) { return book; } book = names.get(name); if (book != null) { return book; } // Check for case-insensitive initial and name matches for (Book b : books) { if (name.equalsIgnoreCase(b.getInitials()) || name.equalsIgnoreCase(b.getName())) { return b; } } return null; }
/** * 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; }
/** * Get a listing of all the available books. * * @param filter * The custom filter specification string * @return a list of (initial, name) string pairs * @see BookInstaller#getInstalledBook(String) */ public String[][] getInstalledBooks(String filter) { List<String[]> reply = new ArrayList<String[]>(); for (Book book : BookInstaller.getInstalledBooks(filter)) { String[] rbook = new String[] { book.getInitials(), book.getName() }; reply.add(rbook); } // If we can't find a book, indicate that. if (reply.isEmpty()) { reply.add(new String[] { "", "No Books installed"}); } return reply.toArray(new String[reply.size()][]); }
protected void handleDelete(final List<Book> documents) { for (final Book document : documents) { if (documentControl.canDelete(document)) { CharSequence msg = getString(R.string.delete_doc, document.getName()); new AlertDialog.Builder(this) .setMessage(msg).setCancelable(true) .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { try { Log.d(TAG, "Deleting:" + document); documentControl.deleteDocument(document); // the doc list should now change reloadDocuments(); } catch (Exception e) { Dialogs.getInstance().showErrorMsg(R.string.error_occurred, e); } } } ) .create() .show(); } } }
/** called during app start-up to restore previous state * * @param jsonObject */ @Override public void restoreState(JSONObject jsonObject) throws JSONException { if (jsonObject!=null) { Log.d(TAG, "Restoring Commentary page state"); if (jsonObject.has("document")) { String document = jsonObject.getString("document"); if (StringUtils.isNotEmpty(document)) { Book book = getSwordDocumentFacade().getDocumentByInitials(document); if (book!=null) { Log.d(TAG, "Restored document:"+book.getName()); // bypass setter to avoid automatic notifications localSetCurrentDocument(book); // allow Bible page to restore shared verse } } } } } }
/** * Remove a Book from 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 be removed from this book list * @throws BookException when an error occurs when performing this method */ public synchronized void removeBook(Book book) throws BookException { // log.debug("unregistering book: {}", bmd.getName()); Activator.deactivate(book); boolean removed = books.remove(book); if (removed) { initials.remove(book.getInitials()); names.remove(book.getName()); fireBooksChanged(instance, book, false); } else { throw new BookException(JSOtherMsg.lookupText("Could not remove unregistered Book: {0}", book.getName())); } }
/** called during app start-up to restore previous state */ @Override public void restoreState(JSONObject jsonObject) throws JSONException { if (jsonObject!=null) { Log.d(TAG, "Restoring Bible page state"); if (jsonObject.has("document")) { String document = jsonObject.getString("document"); if (StringUtils.isNotEmpty(document)) { Log.d(TAG, "State document:"+document); Book book = getSwordDocumentFacade().getDocumentByInitials(document); if (book!=null) { Log.d(TAG, "Restored document:"+book.getName()); // bypass setter to avoid automatic notifications localSetCurrentDocument(book); getCurrentBibleVerse().restoreState(jsonObject.getJSONObject("verse")); } } } } }
@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()); } } } } } }
private Book getBook(String initials) { for (Book book : books) { if (book.getInitials().equals(initials)) { System.out.println("Found:"+book.getName()); return book; } } return null; }
@Override public void startUtterance(@NotNull String utteranceId) { if (keyList != null && keyList.size() > 0) { ABEventBus.getDefault().post(new SpeakProgressEvent(book, keyList.get(0), new TextCommand(currentText, TextCommand.TextType.NORMAL))); ABEventBus.getDefault().post(new SpeakProgressEvent(book, keyList.get(0), new TextCommand(book.getName(), TextCommand.TextType.TITLE))); } }
/** * 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); } }
String name = document.getName(); if (document instanceof AbstractPassageBook) { final AbstractPassageBook bible = (AbstractPassageBook)document;
} else { about = document.getName();
String name = document.getName(); if (document instanceof AbstractPassageBook) { final AbstractPassageBook bible = (AbstractPassageBook)document;