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.