JSword
  1. JSword
  2. JS-269

NPE being thrown by Versification.getPreferredName

    Details

    • Type: Bug Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The Javadoc for Versification.getPreferredName(book) is
      @return The full name of the book or blank if not in this versification

      but if a BibleBook is not in the Versification then an NPE is thrown:

      java.lang.NullPointerException
      org.crosswire.jsword.versification.BibleNames.getPreferredName(BibleNames.java:64)
      org.crosswire.jsword.versification.Versification.getPreferredName(Versification.java:290)
      org.crosswire.jsword.passage.Verse.doGetName(Verse.java:614)
      org.crosswire.jsword.passage.Verse.getName(Verse.java:270)
      org.crosswire.jsword.passage.Verse.getName(Verse.java:255)

      Here is a junit that could be added to VersificationParentTst

      public void testMissingBook() throws Exception {
      if(!v11n.containsBook(BibleBook.TOB))

      { assertEquals("", v11n.getLongName(BibleBook.TOB)); assertEquals("", v11n.getShortName(BibleBook.TOB)); assertEquals("", v11n.getPreferredName(BibleBook.TOB)); }

      }

        Activity

        Hide
        DM Smith added a comment -

        This will still be the case, but I refactored the code so you can ask BibleNames for the preferred name on any BibleBook.

        The problem was that we had code to return the localized name (variations: full, short, abbreviations, preferred, ...), but it was only available via a Versification for the books in that versification.

        The idea was right, but the implementation was wrong. By moving from Versification to BibleNames, we have a single place to get internationalized, localized names independent of the versification.

        Show
        DM Smith added a comment - This will still be the case, but I refactored the code so you can ask BibleNames for the preferred name on any BibleBook. The problem was that we had code to return the localized name (variations: full, short, abbreviations, preferred, ...), but it was only available via a Versification for the books in that versification. The idea was right, but the implementation was wrong. By moving from Versification to BibleNames, we have a single place to get internationalized, localized names independent of the versification.

          People

          • Assignee:
            DM Smith
            Reporter:
            Martin Denham
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: