public boolean test(Book book) { BookCategory bookCategory = book.getBookCategory(); if (book.isLocked()) { return false; } else { return bookCategory.equals(BookCategory.BIBLE) || bookCategory.equals(BookCategory.COMMENTARY) || bookCategory.equals(BookCategory.DICTIONARY) || bookCategory.equals(BookCategory.GENERAL_BOOK) || bookCategory.equals(BookCategory.MAPS); } } }
public String getOsisID() { return getBookCategory().getName() + '.' + getInitials(); }
@Override public Object convert(String input) { return BookCategory.fromString(input); } },
/** * Lookup method to convert from an integer * * @param i the ordinal value of the BookCategory in this enumeration. * @return the i-th BookCategory */ public static BookCategory fromInteger(int i) { for (BookCategory o : BookCategory.values()) { if (i == o.ordinal()) { return o; } } return OTHER; }
/** * @param aType * The type to set. */ public void setBookCategory(BookCategory aType) { BookCategory t = aType; if (t == null) { t = BookCategory.BIBLE; } type = t; putProperty(KEY_CATEGORY, type.toString()); }
/** * Lookup method to convert from a String * * @param name the external name of a BookCategory * @return the matching BookCategory */ public static BookCategory fromExternalString(String name) { for (BookCategory o : BookCategory.values()) { if (o.externalName.equalsIgnoreCase(name)) { return o; } } return OTHER; }
public int compareTo(BookMetaData obj) { int result = this.getBookCategory().compareTo(obj.getBookCategory()); if (result == 0) { result = this.getAbbreviation().compareTo(obj.getAbbreviation()); } if (result == 0) { result = this.getInitials().compareTo(obj.getInitials()); } if (result == 0) { result = this.getName().compareTo(obj.getName()); } return result; }
@Override public Document toOSIS() { OSISUtil.OSISFactory factory = OSISUtil.factory(); Element ele = factory.createTable(); addRow(factory, ele, "Initials", getInitials()); addRow(factory, ele, "Description", getName()); addRow(factory, ele, "Key", getBookCategory().toString()); addRow(factory, ele, "Language", getLanguage().getName()); return new Document(ele); }
/** * Lookup method to convert from a String * * @param name the internal name of a BookCategory * @return the matching BookCategory */ public static BookCategory fromString(String name) { for (BookCategory o : BookCategory.values()) { if (o.name.equalsIgnoreCase(name)) { return o; } } return OTHER; }
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()); } } }
/** called during app close down to save state */ @Override public JSONObject getStateJson() throws JSONException { JSONObject object = new JSONObject(); if (currentDocument!=null) { Log.d(TAG, "Getting json state for "+getBookCategory().getName()); object.put("document", getCurrentDocument().getInitials()); if (this.getKey()!=null) { object.put("key", getKey().getOsisID()); } } return object; }
/** * @param typestr * The string version of the type to set. */ public void setType(String typestr) { BookCategory newType = null; if (typestr != null) { newType = BookCategory.fromString(typestr); } setBookCategory(newType); }
@Override public boolean test(Book book) { return book.getBookCategory().equals(bookCategory) && !book.isLocked(); } });
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; }
/** * If the user has chosen to remember the book (by type) then set the * current book for that type. * * @param book the current Book */ public static void setCurrentBook(Book book) { BookCategory type = book.getBookCategory(); if (type.equals(BookCategory.BIBLE) && isCurrentBible()) { currentBible = book; } }
@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 String normalizeForSearch(String internalKey) { BookMetaData bmd = getBookMetaData(); String keytitle = internalKey; String caseSensitive = bmd.getProperty(SwordBookMetaData.KEY_CASE_SENSITIVE_KEYS); if (!"true".equalsIgnoreCase(caseSensitive) && !BookCategory.DAILY_DEVOTIONS.equals(bmd.getBookCategory())) { return keytitle.toUpperCase(Locale.US); } return keytitle; }
private void adjustBookType() { // The book type represents the underlying category of book. // Fine tune it here. BookCategory focusedCategory = (BookCategory) getValue(KEY_CATEGORY); questionable = focusedCategory == BookCategory.QUESTIONABLE; String modTypeName = getProperty(KEY_MOD_DRV); if (modTypeName == null) { LOGGER.error("Book not supported: malformed conf file for [{}] no {} found.", configAll.getName(), KEY_MOD_DRV); supported = false; return; } String v11n = getProperty(KEY_VERSIFICATION); if (!Versifications.instance().isDefined(v11n)) { LOGGER.error("Book not supported: Unknown versification for [{}]{}={}.", configAll.getName(), KEY_VERSIFICATION, v11n); supported = false; return; } bookType = BookType.fromString(modTypeName); if (bookType == null) { LOGGER.error("Book not supported: malformed conf file for [{}] no book type found", configAll.getName()); supported = false; return; } // The book type represents the underlying category of book. // Fine tune it here. if (focusedCategory == BookCategory.OTHER) { focusedCategory = bookType.getBookCategory(); } setProperty(KEY_CATEGORY, focusedCategory.getName()); }
private String internal2external(String internalKey) { BookMetaData bmd = getBookMetaData(); String keytitle = internalKey; if (BookCategory.DAILY_DEVOTIONS.equals(bmd.getBookCategory()) && keytitle.length() >= 3) { Calendar greg = new GregorianCalendar(); DateFormatter nameDF = DateFormatter.getDateInstance(); String[] spec = StringUtil.splitAll(keytitle, '.'); greg.set(Calendar.MONTH, Integer.parseInt(spec[0]) - 1); greg.set(Calendar.DATE, Integer.parseInt(spec[1])); keytitle = nameDF.format(greg.getTime()); } return keytitle; }
public boolean test(Book book) { return book.getBookCategory().equals(category) && !book.isLocked(); }