[jsword-devel] Confused that GenBookBackend denies containing empty keys

Martin Denham mjdenham at gmail.com
Wed Mar 16 14:47:21 MST 2011


Hi,

I am a bit confused by GenBookBackend.contains(key).  Here is some test
code, btw HodgeSysTheo is from Xiphos repo:

Book book = getBook("HodgeSysTheo");
Key volume1Key = book.getKey("Volume I");  // that is a capital I (*eye*)
not a number one on the end
assertNotNull("Vol 1 not found", volume1Key);
if (!book.contains(volume1Key)) {
System.out.println("Book does not contain a valid key");
}

So you can see that I am getting a key from a GenBook but when I check to
see if the same GenBook contains the key then I get false if the key does
not contain anything.  Maybe this is correct but I thought I would ask just
in case it is a bug.

The bit of code that implements contains() is

            TreeNode node = find(key);   // this returns true
            // Is there an entry?
            if (node == null) {
                return false;
            }

            // Is it non-empty?
            byte[] userData = node.getUserData();

            // Some entries may be empty.
            return userData.length == 8;   // this is false for the test key
being used i.e. 'Volume I'

Either way I can make And Bible work but I just want to check the above is
correct because it surprised me a bit.

Thanks
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20110316/fd024109/attachment.html>


More information about the jsword-devel mailing list