@Override public int count(Passage ref, RestrictionType restrict) { if (ref == null) { return 0; } return ref.countVerses(); } },
public synchronized Iterator<VerseRange> rangeIterator(RestrictionType restrict) { return ref.rangeIterator(restrict); }
public synchronized void add(Key that) { ref.add(that); }
public int compareTo(Key obj) { Passage thatref = (Passage) obj; if (thatref.countVerses() == 0) { if (countVerses() == 0) { return 0; } // that is empty so he should come before me return -1; } if (countVerses() == 0) { // we are empty be he isn't so we are first return 1; } Verse thatfirst = thatref.getVerseAt(0); Verse thisfirst = getVerseAt(0); return getVersification().distance(thatfirst, thisfirst); }
Versification v11n = ref.getVersification(); int maxOrdinal = v11n.maximumOrdinal(); int verses = ref.countVerses(); int ranges = ref.countRanges(RestrictionType.NONE); Iterator<VerseRange> it = ref.rangeIterator(RestrictionType.NONE); while (it.hasNext()) { VerseRange range = it.next();
} else { Passage ref = (Passage) PassageKeyFactory.instance().getKey(parameters.getDocumentVersification(), reference); boolean isSingleVerse = ref.countVerses()==1; boolean hasContent = content.length()>0; boolean hasSeparateRefs = reference.contains(" "); Iterator<VerseRange> it = ref.rangeIterator(RestrictionType.NONE); result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":").append(it.next().getOsisRef()).append("'>"); result.append(content); } else { Iterator<VerseRange> it = ref.rangeIterator(RestrictionType.CHAPTER); boolean isFirst = true; while (it.hasNext()) {
/** * 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; }
public synchronized void addAll(Key key) { ref.addAll(key); }
public synchronized boolean canHaveChildren() { return ref.canHaveChildren(); }
public synchronized int booksInPassage() { return ref.booksInPassage(); }
public synchronized void blur(int by, RestrictionType restrict) { ref.blur(by, restrict); }
public synchronized void clear() { ref.clear(); }
public synchronized void addPassageListener(PassageListener li) { ref.addPassageListener(li); }
@Override public synchronized SynchronizedPassage clone() { SynchronizedPassage clone = null; try { clone = (SynchronizedPassage) super.clone(); synchronized (clone) { clone.ref = (Passage) ref.clone(); } } catch (CloneNotSupportedException e) { assert false : e; } return clone; }
@Override public void addAll(Key key) { //check for key empty. This avoids the AIOBounds with that.getVerseAt, during event firing if (key.isEmpty()) { //nothing to add return; } optimizeWrites(); if (key instanceof BitwisePassage) { BitwisePassage thatRef = (BitwisePassage) key; store.or(thatRef.store); } else { super.addAll(key); } // we do an extra check here because the cost of calculating the // params is non-zero and may be wasted if (suppressEvents == 0 && !key.isEmpty()) { if (key instanceof Passage) { Passage that = (Passage) key; fireIntervalAdded(this, that.getVerseAt(0), that.getVerseAt(that.countVerses() - 1)); } else if (key instanceof VerseRange) { VerseRange that = (VerseRange) key; fireIntervalAdded(this, that.getStart(), that.getEnd()); } else if (key instanceof Verse) { Verse that = (Verse) key; fireIntervalAdded(this, that, that); } } }
/** * Adds a 1-Many mapping, by simply listing out all the properties. There is probably * a better way for storing this, perhaps in a tree - but for simplicity, we're going to list them out. * * @param leftHand the left hand side operand * @param kjvVerses the verses that are mapped by the left hand side */ private void addMappings(final QualifiedKey leftHand, final QualifiedKey kjvVerses) throws NoSuchVerseException { if (leftHand.getAbsentType() == QualifiedKey.Qualifier.ABSENT_IN_LEFT) { this.absentVerses.addAll(kjvVerses.getKey()); } else if (leftHand.getKey().getCardinality() == 1) { add1ToManyMappings(leftHand.getVerse(), kjvVerses); } else { addManyToMany(leftHand, kjvVerses); } }
public boolean canHaveChildren() { return ref.canHaveChildren(); }
public int booksInPassage() { return ref.booksInPassage(); }
@Override public void removeAll(Key key) { optimizeWrites(); if (key instanceof BitwisePassage) { BitwisePassage thatRef = (BitwisePassage) key; store.andNot(thatRef.store); } else { super.removeAll(key); } // we do an extra check here because the cost of calculating the // params is non-zero and may be wasted if (suppressEvents == 0 && !key.isEmpty()) { if (key instanceof Passage) { Passage that = (Passage) key; fireIntervalRemoved(this, that.getVerseAt(0), that.getVerseAt(that.countVerses() - 1)); } else if (key instanceof VerseRange) { VerseRange that = (VerseRange) key; fireIntervalRemoved(this, that.getStart(), that.getEnd()); } else if (key instanceof Verse) { Verse that = (Verse) key; fireIntervalRemoved(this, that, that); } } }
public Iterator<VerseRange> rangeIterator(RestrictionType restrict) { return ref.rangeIterator(restrict); }