/** * Call the support mechanism in AbstractPassage * * @param out * The stream to write our state to * @serialData Write the ordinal number of this verse * @see AbstractPassage#writeObjectSupport(ObjectOutputStream) * @throws IOException * if the read fails */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); // Save off the versification by name out.writeUTF(getVersification().getName()); writeObjectSupport(out); }
public Key next() throws NoSuchElementException { if (!hasNext()) { throw new NoSuchElementException(); } Key retcode = getVersification().decodeOrdinal(next); calculateNext(); return retcode; }
@Override public void retainAll(Key key) { optimizeWrites(); BitSet thatStore = null; if (key instanceof BitwisePassage) { thatStore = ((BitwisePassage) key).store; } else { Versification v11n = getVersification(); thatStore = new BitSet(v11n.maximumOrdinal() + 1); for (Key aKey : key) { int ord = ((Verse) aKey).getOrdinal(); if (store.get(ord)) { thatStore.set(ord); } } } store.and(thatStore); fireIntervalRemoved(this, null, null); }
/** * A shortcut to adding a key, by ordinal. The ordinal needs to be taken * from the same versification as the passage being created. * * @param ordinal * the ordinal */ public void addVersifiedOrdinal(int ordinal) { optimizeWrites(); store.set(ordinal); // we do an extra check here because the cost of calculating the // params is non-zero and may be wasted if (suppressEvents == 0) { Verse verse = getVersification().decodeOrdinal(ordinal); fireIntervalAdded(this, verse, verse); } }
@Override public void blur(int verses, RestrictionType restrict) { assert verses >= 0; optimizeWrites(); raiseNormalizeProtection(); if (!restrict.equals(RestrictionType.NONE)) { super.blur(verses, restrict); } else { optimizeWrites(); raiseEventSuppresion(); raiseNormalizeProtection(); int maximumOrdinal = getVersification().maximumOrdinal(); BitSet newStore = new BitSet(maximumOrdinal + 1); for (int i = store.nextSetBit(0); i >= 0; i = store.nextSetBit(i + 1)) { int start = Math.max(1, i - verses); int end = Math.min(maximumOrdinal, i + verses); for (int j = start; j <= end; j++) { newStore.set(j); } } store = newStore; lowerNormalizeProtection(); if (lowerEventSuppressionAndTest()) { fireIntervalAdded(this, null, null); } } }