<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">That'd be fine.<div><br></div><div>I've been mulling over whether it is a sufficient solution. There are other "Key"s that hold verses (i.e. Passage and it ilk). A VerseRange can certainly contain all the Verses in a Passage. For example, a VerseRange of Genesis 1 contains a Passage of Gen 1:1-2 and Gen 1:10. I don't think this is at all common in real code, but it is possible.</div><div><br></div><div>But don't let that slow progress.</div><div><br></div><div>In Him,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><div><br><div><div>On May 9, 2013, at 9:47 AM, Martin Denham &lt;<a href="mailto:mjdenham@gmail.com">mjdenham@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I can check in a fix if you like.<div><br></div><div style="">Martin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 8 May 2013 15:58, DM Smith <span dir="ltr">&lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">That is the correct solution.<div><div class="h5"><br><div><div>On May 7, 2013, at 11:14 AM, Martin Denham &lt;<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>&gt; wrote:</div>
<br><blockquote type="cite"><div dir="ltr">Hi DM,<div><br></div><div>There are specific contains() implementations in VerseRange. &nbsp;</div><div><div>&nbsp; &nbsp; public boolean contains(Verse that) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return v11n.distance(start, that) &gt;= 0 &amp;&amp; v11n.distance(that, end) &gt;= 0;</div>

<div>&nbsp; &nbsp; }</div></div><div><br></div><div><div>&nbsp; &nbsp; public boolean contains(Key key) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (key instanceof VerseRange) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return contains((VerseRange) key);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>

&nbsp; &nbsp; &nbsp; &nbsp; return false;</div><div>&nbsp; &nbsp; }</div></div><div><br></div><div>The second is being called but returns false because key is not a VerseRange. If the implementation of VerseRange.contains(Key) is the problem then another clause added at the end of the method might be one way to fix it, like:</div>

<div><div>&nbsp; &nbsp; public boolean contains(Key key) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (key instanceof VerseRange) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return contains((VerseRange) key);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (key instanceof Verse) {</div>

<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return contains((Verse) key);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; return false;</div><div>&nbsp; &nbsp; }</div></div><div><br></div></div><div>Martin</div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On 7 May 2013 14:12, DM Smith <span dir="ltr">&lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Sorry for not replying earlier. Have been on holiday.<br>
<br>
This conundrum should bee seen as a bug. Both should return the same value.<br>
<br>
I have an idea of what is happening (I have a masters degree in computer science for compiler construction), but until I trace it I won't be sure. I think that it is compile time determination of what is being called.<br>


<br>
In the gen_all case, it is known that it is a VerseRange and that VerseRange has a more specific contains(Verse). So that is called.<br>
<br>
In the gen_allKey case, it is no longer a VerseRange but a Key (which should not know anything about a Verse, since it is supposed to work for all kinds of Keys). So it cannot call contains(Verse) but only contains(Key).<br>


<br>
I'll see what I can find out.<br>
<br>
-- DM<br>
<div><br>
On May 4, 2013, at 5:34 AM, Martin Denham &lt;<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Here is an interesting problem (based on VerseRangeTest.java):<br>
&gt;<br>
&gt; &nbsp; &nbsp; private VerseRange gen_all = ...;<br>
&gt;<br>
&gt; &nbsp; &nbsp; public void testKeyContainsVerse() {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; // this passes<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; assertTrue(gen_all.contains(gen11));<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; // this fails<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Key gen_allKey = gen_all;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; assertTrue(gen_allKey.contains(gen11));<br>
&gt; &nbsp; &nbsp; }<br>
&gt;<br>
&gt; This caught me out for a while. &nbsp;I think the second assert should pass but Key is an interface with a single non-overloaded contains():<br>
&gt; &nbsp; &nbsp; boolean contains(Key key);<br>
&gt;<br>
&gt; Whereas VerseRange contains overloaded methods like contains(Verse) that are not called because the Key interface is being used. &nbsp;At least that is what I think is happening.<br>
&gt;<br>
&gt; Is this a bug?<br>
&gt;<br>
&gt; Martin<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; _______________________________________________<br>
&gt; jsword-devel mailing list<br>
&gt; <a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br>
&gt; <a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
<br>
<br>
_______________________________________________<br>
jsword-devel mailing list<br>
<a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
</blockquote></div><br></div>
_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
</blockquote></div><br></div></div></div><br>_______________________________________________<br>
jsword-devel mailing list<br>
<a href="mailto:jsword-devel@crosswire.org">jsword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org">jsword-devel@crosswire.org</a><br>http://www.crosswire.org/mailman/listinfo/jsword-devel<br></blockquote></div><br></div></body></html>