use of com.tyndalehouse.step.core.models.BookName in project step by STEPBible.
the class JSwordMetadataServiceImpl method getBibleBookNames.
/**
* returns a list of matching names or references in a particular book
*
* @param bookStart the name of the matching key to look across book names
* @param version the name of the version, defaults to ESV if not found
* @param bookScope a scope that reduces the search
* @param autoLookupSingleBooks true to indicate a single book should resolve to chapters
* @return a list of matching bible book names
*/
private List<BookName> getBibleBookNames(final String bookStart, final String version, final String bookScope, boolean autoLookupSingleBooks) {
final String lookup = isBlank(bookStart) ? "" : bookStart;
final Versification versification = this.versificationService.getVersificationForVersion(version);
final List<BookName> books = getBooks(lookup, versification, bookScope, autoLookupSingleBooks);
if (books.isEmpty()) {
return getBooks(lookup, Versifications.instance().getVersification(Versifications.DEFAULT_V11N), bookScope, autoLookupSingleBooks);
}
return books;
}
use of com.tyndalehouse.step.core.models.BookName in project step by STEPBible.
the class JSwordMetadataServiceImpl method getChapters.
/**
* Returns the list of chapters
*
* @param versification the versification
* @param book the book
* @return a list of books
*/
private List<BookName> getChapters(final Versification versification, final BibleBook book) {
final int lastChapter = versification.getLastChapter(book);
final List<BookName> chapters = new ArrayList<BookName>();
// we add the whole book + all the chapters
BookName.Section section = DivisionName.BIBLE.contains(book) ? BookName.Section.BIBLE_BOOK : BookName.Section.APOCRYPHA;
chapters.add(new BookName(versification.getShortName(book), versification.getLongName(book), section, versification.getLastChapter(book) != 1, book, false, book.getOSIS()));
for (int ii = 1; ii <= lastChapter; ii++) {
// final char f = Character.toUpperCase(searchSoFar.charAt(0));
// make sure first letter is CAPS, followed by the rest of the word and the chapter number
final String chapNumber = String.format(BOOK_CHAPTER_FORMAT, versification.getShortName(book), ii);
final String longChapNumber = String.format(BOOK_CHAPTER_FORMAT, versification.getLongName(book), ii);
chapters.add(new BookName(chapNumber, longChapNumber, BookName.Section.PASSAGE, false, book, true, JSwordUtils.getChapterOsis(book, ii)));
}
return chapters;
}
use of com.tyndalehouse.step.core.models.BookName in project step by STEPBible.
the class JSwordPassageServiceImplTest method testGetBibleBooks.
/**
* Tests that getting a bible book returns the correct set of names
*/
@Test
public void testGetBibleBooks() {
final JSwordMetadataServiceImpl jsi = new JSwordMetadataServiceImpl(TestUtils.mockVersificationService(), null);
final List<BookName> bibleBookNames = jsi.getBibleBookNames("Ma", "ESV_th", null);
final String[] containedAbbrevations = new String[] { "Mal", "Mat", "Mar" };
for (final String s : containedAbbrevations) {
boolean found = false;
for (final BookName b : bibleBookNames) {
if (s.equalsIgnoreCase(b.getShortName())) {
found = true;
break;
}
}
if (!found) {
fail(s + " was not found");
}
}
}
use of com.tyndalehouse.step.core.models.BookName in project step by STEPBible.
the class InternationalRangeServiceImpl method getBooks.
public List<BookName> getBooks() {
final Locale userLocale = clientSessionProvider.get().getLocale();
List<BookName> bookNames = BOOK_NAMES.get(userLocale);
if (bookNames == null) {
bookNames = new ArrayList<BookName>();
synchronized (BOOK_NAMES) {
ResourceBundle bundle = ResourceBundle.getBundle("InteractiveBundle", userLocale);
for (final String s : this.ranges) {
bookNames.add(new BookName(bundle.getString(s + RANGE_SUFFIX), bundle.getString(s), BookName.Section.BIBLE_SECTION, false, s));
}
}
BOOK_NAMES.put(userLocale, bookNames);
}
return bookNames;
}
use of com.tyndalehouse.step.core.models.BookName in project step by STEPBible.
the class ReferenceSuggestionServiceImpl method getSampleData.
/**
* Returns all 66 books (or more) of the Bible.
*
* @param context the context
* @return the list of all book names
*/
private BookName[] getSampleData(final SuggestionContext context) {
final List<BookName> books = new ArrayList<BookName>();
final String masterBook = getDefaultedVersion(context);
final Versification masterV11n = this.versificationService.getVersificationForVersion(masterBook);
final Iterator<BibleBook> bookIterator = masterV11n.getBookIterator();
while (bookIterator.hasNext()) {
final BibleBook book = bookIterator.next();
addBookName(books, book, masterV11n);
}
return books.toArray(new BookName[books.size()]);
}
Aggregations