Uploaded image for project: 'JSword'
  1. JSword
  2. JS-175

indexOf a valid Key in Josephus returns -1

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 1.6.1
    • Fix Version/s: None
    • Component/s: o.c.jsword.passage
    • Labels:
      None
    • Environment:

      All

      Description

      Here is my test:

      Book book = getBook("Josephus");
      assertNotNull("Josephus not available", book);

      // find a key and print out it's name - this works
      final String SECTION_2 = "Section 2";
      Key key = book.getKey(SECTION_2);
      assertEquals(SECTION_2, key.getName());

      // but we can't get it's index - this returns -1
      int keyPos = book.getGlobalKeyList().indexOf(key);
      assertFalse("Could not get index of a valid key", -1==keyPos);

      When dealing with a book having TreeKeys the top level Key returned by book.getGlobalKeyList is not a TreeKey but a KeyList which therefore does not automatically search it's children. So I wonder if SwordGenBook.global could be a TreeKey rather than a ReadOnlyKeyList.

      Maybe the way it works is the way it should work but I am not sure. Now I realise what is happening I could just call indexOf on each child of the globalKeyList but I think it would be more elegant if globalKeyList.indexOf returned a key from lower down in the tree.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: