@Override public Passage createEmptyPassage(Versification v11n) { return new RangedPassage(v11n); } },
/** Simplify creation of an empty passage object of the default type, with the required v11n. * * @param versification required v11n for new Passage * @return empty Passage */ private Passage createEmptyPassage(Versification versification) { return new RangedPassage(versification); }
@Override public Passage createPassage(Versification v11n, String passage, Key basis) throws NoSuchVerseException { if (passage == null || passage.length() == 0) { return createEmptyPassage(v11n); } return new RangedPassage(v11n, passage, basis); }
public RangedPassage convert(RangedPassage rangedPassage, Versification toVersification) { RangedPassage result = new RangedPassage(toVersification); Iterator<VerseRange> iter = rangedPassage.rangeIterator(RestrictionType.NONE); while (iter.hasNext()) { result.add(convert(iter.next(), toVersification)); } return result; }
/** * Maps a whole passage, and does so verse by verse. We can't do any better, since, we may for * example have: * Ps.1.1-Ps.1.10 => Ps.1.2-Ps.1.11 so one would think we can simply map each of the start and end verses. * However, this would be inaccurate since verse 9 might map to verse 12, 13, etc. * * @param key the key if the source versification * @param target the target versification * @return the new key in the new versification */ public Passage map(final Passage key, final Versification target) { if (key.getVersification().equals(target)) { return key; } Passage newPassage = new RangedPassage(target); Iterator<Key> verses = key.iterator(); while (verses.hasNext()) { Verse verse = (Verse) verses.next(); newPassage.addAll(this.mapVerse(verse, target)); } return newPassage; }
/** * @param kjvVerses the list of keys * @return the aggregate key */ private VerseKey getKeyFromQualifiedKeys(Versification versification, final List<QualifiedKey> kjvVerses) { final VerseKey finalKey = new RangedPassage(versification); for (QualifiedKey k : kjvVerses) { // we simply ignore everything else at this stage. The other bits // and pieces are used while we're converting // from one to the other. if (k.getKey() != null) { finalKey.addAll(k.getKey()); } } return finalKey; }
/** * This is a last attempt at trying to get something, on the basis that * something is better than nothing. * * @param targetVersification the target versification * @param kjvVerses the verses in the KJV versification. * @return the possible verses in the target versification, no guarantees * made */ private VerseKey guessKeyFromKjvVerses(final Versification targetVersification, final List<QualifiedKey> kjvVerses) { final VerseKey finalKeys = new RangedPassage(targetVersification); for (QualifiedKey qualifiedKey : kjvVerses) { if (qualifiedKey.getKey() != null) { final VerseKey key = qualifiedKey.reversify(targetVersification).getKey(); if (key != null) { //verse key exists in target versification finalKeys.addAll(key); } } } return finalKeys; }
VerseKey finalKeys = new RangedPassage(targetVersification); for (QualifiedKey qualifiedKey : kjvVerses) { final VerseKey verseKey = targetMapper.unmap(qualifiedKey);
@Override public void optimizeReads() { raiseEventSuppresion(); // We have to create the cached versions of these separately // so that the calculations made by addAll(this) can // safely call methods like countVerses() without any // danger of them being optimized before the optimizations // are ready for use. DistinctPassage dtemp = new DistinctPassage(getVersification()); dtemp.raiseEventSuppresion(); dtemp.addAll(this); dtemp.lowerEventSuppressionAndTest(); RangedPassage rtemp = new RangedPassage(getVersification()); rtemp.raiseEventSuppresion(); rtemp.addAll(this); rtemp.lowerEventSuppressionAndTest(); distinct = dtemp; ranged = rtemp; // This is just an optimization so we dont need to fire any events lowerEventSuppressionAndTest(); }