/** * The bookMap contains one slot for every BibleBook, indexed by it's ordinal value. * The value of that entry is the position of the book in the BookList. * If the BibleBook is not present in books, it's value is -1. */ private void initialize() { bookMap = new int[BibleBook.values().length + 1]; // Initialize all slots to -1 for (BibleBook b : BibleBook.values()) { bookMap[b.ordinal()] = -1; } // Fill in the position of the books into that list for (int i = 0; i < books.length; i++) { bookMap[books[i].ordinal()] = i; } }
@Override public int hashCode() { return book.hashCode(); }
/** * Gets the common name of the verse, excluding any !abc sub-identifier * @return the verse OSIS-ID, excluding the sub-identifier */ private StringBuilder getVerseIdentifier() { StringBuilder buf = new StringBuilder(); buf.append(book.getOSIS()); buf.append(Verse.VERSE_OSIS_DELIM); buf.append(chapter); buf.append(Verse.VERSE_OSIS_DELIM); buf.append(verse); return buf; }
private void store(ResourceBundle resources, BibleBook book, Map fullMap, Map shortMap, Map altMap) { String osisName = book.getOSIS(); String fullBook = getString(resources, osisName + FULL_KEY); String shortBook = getString(resources, osisName + SHORT_KEY); if (shortBook.length() == 0) { shortBook = fullBook; } String altBook = getString(resources, osisName + ALT_KEY); BookName bookName = new BookName(locale, BibleBook.fromOSIS(osisName), fullBook, shortBook, altBook); books.put(book, bookName); fullMap.put(bookName.getNormalizedLongName(), bookName); shortMap.put(bookName.getNormalizedShortName(), bookName); String[] alternates = StringUtil.split(BookName.normalize(altBook, locale), ','); for (int j = 0; j < alternates.length; j++) { altMap.put(alternates[j], bookName); } }
public void restoreState(JSONObject jsonObject) throws JSONException { if (jsonObject!=null) { if (jsonObject.has("versification") && jsonObject.has("bibleBook")) { Versification v11n = Versifications.instance().getVersification(jsonObject.getString("versification")); int bibleBookNo = jsonObject.getInt("bibleBook"); int chapterNo = jsonObject.getInt("chapter"); int verseNo = jsonObject.getInt("verseNo"); mainVerse = new Verse(v11n, BibleBook.values()[bibleBookNo], chapterNo, verseNo, true); } } } }
StringBuilder buf = new StringBuilder(); if (book.isShortBook()) { if (verseBase == null || verseBase.book != book) { buf.append(BibleNames.instance().getPreferredName(book));
private Set<BibleBook> fromString(String list) { Set<BibleBook> books = new LinkedHashSet<BibleBook>(list.length() / 2); final String[] bookOsis = StringUtil.split(list, ' '); for (String s : bookOsis) { books.add(BibleBook.fromExactOSIS(s)); } return books; }
/** * Get a book from its name. * * @param find * The string to identify * @return The BibleBook, On error null */ public BibleBook getBook(String find) { BibleBook book = null; if (containsLetter(find)) { book = BibleBook.fromOSIS(find); if (book == null) { book = getLocalizedBibleNames().getBook(find, false); } if (book == null) { book = englishBibleNames.getBook(find, false); } if (book == null) { book = getLocalizedBibleNames().getBook(find, true); } if (book == null) { book = englishBibleNames.getBook(find, true); } } return book; }
private String toString(Set<BibleBook> books) { StringBuilder sb = new StringBuilder(books.size() * 8); for (Iterator<BibleBook> iterator = books.iterator(); iterator.hasNext(); ) { BibleBook b = iterator.next(); sb.append(b.getOSIS()); if (iterator.hasNext()) { sb.append(' '); } } return sb.toString(); }
/** default book for use when jumping into the middle of passage selection */ public int getDefaultBibleBookNo() { return Arrays.binarySearch(BibleBook.values(), pageControl.getCurrentBibleVerse().getBook()); }
/** * Some IBT books mistakenly had dummy empty verses which returned the following for verse 1,2,... lastVerse-1 * <chapter eID="gen7" osisID="1Esd.1"/> * <chapter eID="gen1010" osisID="Mal.3"/> */ private boolean isProbablyEmptyVerseInDocument(Book document, Verse verse) { int rawTextLength = ((AbstractBook)document).getBackend().getRawTextLength(verse); if (verse.getBook().isShortBook()) { return isProbablyShortBookEmptyVerseStub(rawTextLength); } else { return isProbablyEmptyVerseStub(rawTextLength); } }
private Verse parseOsisID(final Versification v11n, final List<String> osisIDParts) { final BibleBook b = BibleBook.fromExactOSIS(osisIDParts.get(0)); if (b == null) { return null; } // Allow a Verse to have a sub identifier on the last part. // We should use it, but throwing it away for now. String[] endParts = StringUtil.splitAll(osisIDParts.get(2), Verse.VERSE_OSIS_SUB_PREFIX); String subIdentifier = null; if (endParts.length == 2 && endParts[1].length() > 0) { subIdentifier = endParts[1]; } return new Verse(v11n, b, Integer.parseInt(osisIDParts.get(1)), Integer.parseInt(endParts[0]), subIdentifier); }
/** * Does this Versification contain the BibleBook. * * @param book * @return true if it is present. */ public boolean contains(BibleBook book) { return book != null && bookMap[book.ordinal()] != -1; }
int otCount = 0; int ncCount = 0; BibleBook[] bibleBooks = BibleBook.values(); for (BibleBook book : bibleBooks) { int ordinal = book.ordinal(); if (ordinal > BibleBook.INTRO_OT.ordinal() && ordinal < BibleBook.INTRO_NT.ordinal()) { ++ntCount; } else if (ordinal > BibleBook.INTRO_NT.ordinal() && ordinal <= BibleBook.REV.ordinal()) { ++otCount; } else { shortNT = new HashMap<String, BookName>(ntCount); altNT = new HashMap<String, BookName>(ntCount); for (int i = BibleBook.MATT.ordinal(); i <= BibleBook.REV.ordinal(); ++i) { BibleBook book = bibleBooks[i]; store(resources, book, fullNT, shortNT, altNT); shortOT = new HashMap<String, BookName>(otCount); altOT = new HashMap<String, BookName>(otCount); for (int i = BibleBook.GEN.ordinal(); i <= BibleBook.MAL.ordinal(); ++i) { BibleBook book = bibleBooks[i]; store(resources, book, fullOT, shortOT, altOT); store(resources, BibleBook.INTRO_OT, fullNC, shortNC, altNC); store(resources, BibleBook.INTRO_NT, fullNC, shortNC, altNC); for (int i = BibleBook.REV.ordinal() + 1; i < bibleBooks.length; ++i) { BibleBook book = bibleBooks[i]; store(resources, book, fullNC, shortNC, altNC);
public List<BookmarkDto> getBookmarksInBook(BibleBook book) { Log.d(TAG, "about to getBookmarksInPassage:"+book.getOSIS()); List<BookmarkDto> bookmarkList = new ArrayList<>(); Cursor c = db.query(BookmarkQuery.TABLE, BookmarkQuery.COLUMNS, BookmarkColumn.KEY+" LIKE ?", new String []{String.valueOf(book.getOSIS()+".%")}, null, null, null); try { if (c.moveToFirst()) { while (!c.isAfterLast()) { BookmarkDto bookmark = getBookmarkDto(c); bookmarkList.add(bookmark); c.moveToNext(); } } } finally { c.close(); } Log.d(TAG, "bookmarksInPassage set to " + bookmarkList.size() + " item long list"); return bookmarkList; }
final BibleBook book = BibleBook.fromExactOSIS(bookName);
public List<MyNoteDto> getMyNotesInBook(BibleBook book) { Log.d(TAG, "about to getMyNotesInPassage:"+book.getOSIS()); List<MyNoteDto> notesList = new ArrayList<MyNoteDto>(); Cursor c = db.query(MyNoteQuery.TABLE, MyNoteQuery.COLUMNS, MyNoteColumn.KEY+" LIKE ?", new String []{String.valueOf(book.getOSIS()+".%")}, null, null, null); try { if (c.moveToFirst()) { while (!c.isAfterLast()) { MyNoteDto mynote = getMyNoteDto(c); notesList.add(mynote); c.moveToNext(); } } } finally { c.close(); } Log.d(TAG, "myNotesInPassage set to " + notesList.size() + " item long list"); return notesList; }