[jsword-devel] AccuracyType for single chapter books

DM Smith dmsmith555 at yahoo.com
Fri Dec 28 10:00:45 MST 2007


On Dec 28, 2007, at 9:38 AM, Brian Fernandes wrote:

> In my application, I create a key based on the book and chapter  
> selected
> by a user and pass it on to the JSWord API to get the corresponding
> text. So if you select Genesis and chapter 1, I get the key using
> Book#getKey("Genesis.1"); The corresponding text is the first  
> chapter of
> Genesis. OK.
> If I do the same for a single chapter book though, like Jude, the  
> text I
> get back is just the first verse of that chapter and not the first
> chapter as I expected. (The key I used is "Jude.1").

Verse is a special kind of key. It is merely a holder of book number  
(i.e. 1-66), chapter and verse.
At this time, these have to be non-zero. But these should allow 0 to  
represent introductions.

A VerseRange is a special kind of range in that it starts at one verse  
and ends at another, inclusive of both.

Here is how the Book/Chapter picker in BibleDesktop does it:
Verse start = new Verse(BibleInfo.getBookNumber("Jude"), 1, 1);
Verse end = start.getLastVerseInChapter();
VerseRange singleChapter = new VerseRange(start, end);

If your program can do this, this would be best.


>
>
> I stepped into the code and this seems to be because the AccuracyType
> for "Genesis.1" is BOOK_CHAPTER, while the type for "Jude.1" is
> BOOK_VERSE. These results are perfect according to the javadoc for  
> that
> method. But these results also cause
> VerseRangeFactory#fromString(String) to return a range covering just
> that one verse instead of the entire chapter, consequently, I get a
> single verse back instead of the chapter.
>
> My expectation is: Jude.1 and Genesis.1 should both be BOOK_CHAPTER
> type, but I see that there is code which explicitly returns BOOK_VERSE
> for the former because it has only one chapter. I'm sure there is a
> reason for this, but I cannot figure this out. Is my expectation
> invalid? If so, how should I construct my key so that I get back the
> entire chapter instead of just that one verse? I'm using code nearly
> identical to APIExamples#readStyledText.

The whole AccuracyType code is meant to be able to parse arbitrary  
user input into meaningful Verse objects. It should not be used  
directly.

Jude 1 is verse one of the book of Jude. And Jude 5 is verse 5 of  
chapter 1 of the book of Jude.

The engine allows for values like osisIDs to be used so "Jude.1.1-ff"  
will give you what you expect.

"ff" is an extension that means the last verse or the last chapter,  
depending on the context.

The "proper" way to parse user input into a key is to call:
Key k = book.getKey(userInput); // Currently this only is meaningful  
for Bibles.

Or:

Key k = PassageKeyFactory.instance().getKey(userInput);

So
Key k = PassageKeyFactory.instance().getKey(bookName + "." + chapter +  
".1-ff");
would return a single chapter.

(I'm doing this from memory so I may have made a typo :)

May God bless your efforts!

Serving Christ Together,
	DM



More information about the jsword-devel mailing list