public VerseRange getNextVerseRange(AbstractPassageBook document, VerseRange verseRange, boolean continueToNextChapter) { Versification v11n = verseRange.getVersification(); int verseCount = verseRange.getCardinality(); // shuffle forward Verse start = verseRange.getStart(); Verse end = verseRange.getEnd(); int i=0; while (i++<verseCount && (continueToNextChapter || !v11n.isEndOfChapter(end))) { start = getNextVerse(document, start); end = getNextVerse(document, end); } return new VerseRange(v11n, start, end); }
@Override public String toString() { return getName(); }
public int compareTo(TalliedVerseRange that) { if (that.tally == this.tally) { return this.range.compareTo(that.range); } return that.tally - this.tally; }
/** * Ctor */ protected VerseIterator(VerseRange range) { v11n = range.getVersification(); nextVerse = range.getStart(); total = range.getCardinality(); count = 0; }
public VerseRange convert(VerseRange verseRange, Versification toVersification) { Verse startVerse = verseRange.getStart(); Verse endVerse = verseRange.getEnd(); Verse convertedStartVerse = convert(startVerse, toVersification); Verse convertedEndVerse = convert(endVerse, toVersification); return new VerseRange(toVersification, convertedStartVerse, convertedEndVerse); }
@Override public VerseRange toRange(Versification v11n, Verse verse, int count) { Verse end = verse; if (count > 1) { end = v11n.add(verse, count - 1); } return new VerseRange(v11n, verse, end); } },
/** * Allow override of the key, particular useful if we're constructing in 2 stages like the offset mechanism * * @param key the new key */ private void setKey(final VerseRange key) { if (key.getCardinality() == 1) { this.qualifiedKey = key.getStart(); } else { this.qualifiedKey = key; } this.wholeKey = this.qualifiedKey.getWhole(); }
public VerseRange next() { if (next == null) { next = real.next(); } if (next == null) { throw new NoSuchElementException(); } // So we know what is broadly next, however the range might need // splitting according to restrict if (restrict.isSameScope(next.getVersification(), next.getStart(), next.getEnd())) { return replyNext(); } return splitNext(); }
public void remove(Key obj) { optimizeWrites(); VerseRange thatRange = toVerseRange(getVersification(), obj); boolean removed = false; // This allows us to modify store which iterating through a copy Set<Key> newStore = new TreeSet<Key>(); newStore.addAll(store); // go through all the VerseRanges for (Key aKey : newStore) { // if this range touches the range to be removed ... VerseRange thisRange = (VerseRange) aKey; if (thisRange.overlaps(thatRange)) { // ... remove it and add the remainder store.remove(thisRange); VerseRange[] vra = VerseRange.remainder(thisRange, thatRange); for (int i = 0; i < vra.length; i++) { store.add(vra[i]); } removed = true; } } if (removed) { normalize(); } // we do an extra check here because the cost of calculating the // params is non-zero an may be wasted if (suppressEvents == 0) { fireIntervalRemoved(this, thatRange.getStart(), thatRange.getEnd()); } }
Verse vrStart = vr.getStart(); Verse start = vrStart.reversify(versification); if (vr.getCardinality() > 1) { end = versification.add(start, vr.getCardinality() - 1); return start != null && end != null ? new QualifiedKey(new VerseRange(versification, start, end)) : new QualifiedKey(versesKey);
/** * Merge 2 VerseRanges together. The resulting range will encompass * Everything in-between the extremities of the 2 ranges. * * @param a * The first verse range to be merged * @param b * The second verse range to be merged */ public VerseRange(VerseRange a, VerseRange b) { v11n = a.v11n; shaper = new NumberShaper(); start = v11n.min(a.getStart(), b.getStart()); end = v11n.max(a.getEnd(), b.getEnd()); verseCount = calcVerseCount(); }
public String getName() { if (PassageUtil.isPersistentNaming() && originalName != null) { return originalName; } StringBuilder retcode = new StringBuilder(); Iterator<VerseRange> it = rangeIterator(RestrictionType.NONE); Verse current = null; while (it.hasNext()) { VerseRange range = it.next(); retcode.append(range.getName(current)); // FIXME: Potential bug. According to iterator contract hasNext and // next must be paired. if (it.hasNext()) { retcode.append(AbstractPassage.REF_PREF_DELIM); } current = range.getStart(); } return retcode.toString(); }
@Test public void testVerseRange() { BookmarkDto newBookmarkDto = new BookmarkDto(); final VerseRange verseRange = new VerseRange(KJV_VERSIFICATION, new Verse(KJV_VERSIFICATION, BibleBook.PS, 17, 2), new Verse(KJV_VERSIFICATION, BibleBook.PS, 17, 5)); newBookmarkDto.setVerseRange(verseRange); BookmarkDto newDto = bookmarkControl.addOrUpdateBookmark(newBookmarkDto); assertThat(newDto.getVerseRange(), equalTo(verseRange)); assertThat(bookmarkControl.isBookmarkForKey(verseRange.getStart()), equalTo(true)); }
@Override public Verse createStartVerse(Versification v11n, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException { if (verseRangeBasis == null) { // TRANSLATOR: The user supplied a verse reference but did not give the book or chapter of the Bible. throw new NoSuchVerseException(JSMsg.gettext("Book and chapter are missing")); } BibleBook book = verseRangeBasis.getEnd().getBook(); int chapter = verseRangeBasis.getEnd().getChapter(); int verse = getVerse(v11n, book, chapter, parts[0]); return new Verse(v11n, book, chapter, verse, getSubIdentifier(parts)); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ConvertibleVerseRange that = (ConvertibleVerseRange) o; return originalVerseRange.equals(that.getVerseRange(originalVerseRange.getVersification())); }
public VerseRange getWhole() { if (isWhole()) { return this; } return new VerseRange(v11n, start.getWhole(), end.getWhole()); }
next = it.next(); if (last != null && next.adjacentTo(last)) { VerseRange merge = new VerseRange(last, next);
for (BookmarkDto bookmarkDto : bookmarkList) { VerseRange bookmarkVerseRange = bookmarkDto.getVerseRange(requiredVersification); if (passage.contains(bookmarkVerseRange.getStart())) { final List<LabelDto> bookmarkLabels = db.getBookmarkLabels(bookmarkDto); if(bookmarkLabels.isEmpty()) { for (Verse verse : bookmarkVerseRange.toVerseArray()) { Set<BookmarkStyle> stylesSet = bookmarkStylesByVerseNoInPassage.get(verse.getVerse()); if(stylesSet != null) {