[jsword-devel] Versification and Bible book names
DM Smith
dmsmith at crosswire.org
Tue Feb 25 14:20:20 MST 2014
On Feb 25, 2014, at 4:13 PM, Martin Denham <mjdenham at gmail.com> wrote:
> Bible book names are currently looked up in Versification code but I am not sure this is correct because support for getting the name of a Bible book not in the versification is not provided?.
>
> Versifications throw a NullPointerException if an attempt is made to get the name of a Bible book not contained in that versification.
>
> I keep changing code to work around the above situation but realistically if the user is in the NT and then chooses a Module that doesn't support the NT it would be better if attempting to get the name (even to log an error) did not throw an exception.
>
> Here is a simple junit to demonstrate the issue:
>
> Versification MT = Versifications.instance().getVersification("MT");
> Verse v = new Verse(MT, BibleBook.MATT, 1, 1);
> v.toString();
>
> Throws:
> java.lang.NullPointerException
> at org.crosswire.jsword.versification.BibleNames.getPreferredName(BibleNames.java:64)
> at org.crosswire.jsword.versification.Versification.getPreferredName(Versification.java:290)
> at org.crosswire.jsword.passage.Verse.doGetName(Verse.java:622)
> at org.crosswire.jsword.passage.Verse.getName(Verse.java:271)
> at org.crosswire.jsword.passage.Verse.getName(Verse.java:256)
> at org.crosswire.jsword.passage.Verse.toString(Verse.java:249)
>
> What do you think?
I think it is ugly and needs to be fixed. Looks like you are ahead of me. I still have work to do in Bible Desktop to get it to work.
Off the top of my head, a Verse should be able to be constructed from any input and fail only when validated explicitly. Then it should throw a "NoSuchVerseException".
In His Service,
DM
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4145 bytes
Desc: not available
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20140225/01dc147f/attachment.p7s>
More information about the jsword-devel
mailing list