[jsword-devel] [JIRA] Created: (JS-175) indexOf a valid Key in Josephus returns -1
Martin Denham (JIRA)
jira at crosswire.org
Thu Mar 10 14:02:02 MST 2011
indexOf a valid Key in Josephus returns -1
------------------------------------------
Key: JS-175
URL: http://www.crosswire.org/bugs/browse/JS-175
Project: JSword
Issue Type: Bug
Components: o.c.jsword.passage
Affects Versions: 1.6.1
Environment: All
Reporter: Martin Denham
Assignee: DM Smith
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.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jsword-devel
mailing list