[jsword-devel] Iterating over "Pericopes"

DM Smith dmsmith at crosswire.org
Sat Jan 18 19:47:09 MST 2014


On Jan 18, 2014, at 8:26 PM, Douglas Campos <qmx at qmx.me> wrote:

> Is there an easy way to do this which I'm missing?

I'm not sure I understand your question. A pericope is a contiguous collection of one or more verses. In JSword, this is a Verse or a VerseRange.

In JSword, we also have a Passage, not a very good name, which is a collection of one or more verses that may or may not be a contiguous collection. That is it is a collection of non-overlapping Verses and VerseRanges.

All are derived from Key. Key defines iterator() which will return atomic parts. For a dictionary, it might be over terms.

In the case of a Passage, VerseRange or Verse, it will return each Verse contained in canonical order.

Passage defines rangeIterator. While passage is was developed for Verses, it also makes sense for any work. A range starts with an indexed entry and continues for a while. We just haven't abstracted that yet.

The rangeIterator can be influenced by a RestrictionType, which defines boundaries beyond which a range cannot extend. At one time we had 3, but now we have two types. NONE and BOOK. So given the entire Bible, NONE will return a single VerseRange key, but Book will return one for each book.

So iteration is simply a loop over Verses or VerseRanges.

E.g. Verses
Passage p = ....; // Could also be a VerseRange.
for (Key key : p) {
   Verse verse = (Verse) key;
   ...
} 

The complexity I described in an earlier post was how the internal data structures of a RangedPassage is maintained with each call to p.add(Key).

In Him,
DM
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4145 bytes
Desc: not available
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20140118/01339c9f/attachment.p7s>


More information about the jsword-devel mailing list