@Override public BitwisePassage clone() { // This gets us a shallow copy BitwisePassage copy = (BitwisePassage) super.clone(); copy.store = (BitSet) store.clone(); return copy; }
@Override public RangedPassage clone() { // This gets us a shallow copy RangedPassage copy = (RangedPassage) super.clone(); // I want to just do the following // copy.store = (SortedSet) store.clone(); // However SortedSet is not Cloneable so I can't // Watch out for this, I'm not sure if it breaks anything. copy.store = new TreeSet<VerseRange>(); copy.store.addAll(store); return copy; }
/** * Get a copy of ourselves. Points to note: * <ul> * <li>Call clone() not new() on member Objects, and on us. * <li>Do not use Copy Constructors! - they do not inherit well. * <li>Think about this needing to be synchronized * <li>If this is not cloneable then writing cloneable children is harder * </ul> * * @return A complete copy of ourselves */ @Override public DistinctPassage clone() { // This gets us a shallow copy DistinctPassage copy = (DistinctPassage) super.clone(); // I want to just do the following // copy.store = (SortedSet) store.clone(); // However SortedSet is not Cloneable so I can't // Watch out for this, I'm not sure if it breaks anything. copy.store = new TreeSet<Key>(); copy.store.addAll(store); return copy; }
@Override public PassageTally clone() { // This gets us a shallow copy PassageTally copy = (PassageTally) super.clone(); copy.board = board.clone(); return copy; }
public Passage trimRanges(int count, RestrictionType restrict) { optimizeWrites(); raiseNormalizeProtection(); int i = 0; boolean overflow = false; Passage remainder = this.clone(); Iterator<VerseRange> it = rangeIterator(restrict); while (it.hasNext()) { i++; Key range = it.next(); if (i > count) { remove(range); overflow = true; } else { remainder.remove(range); } } lowerNormalizeProtection(); // The event notification is done by the remove above if (overflow) { return remainder; } return null; }
public void blur(int verses, RestrictionType restrict) { optimizeWrites(); raiseEventSuppresion(); raiseNormalizeProtection(); Passage temp = this.clone(); Iterator<VerseRange> it = temp.rangeIterator(RestrictionType.NONE); while (it.hasNext()) { VerseRange range = restrict.blur(getVersification(), it.next(), verses, verses); add(range); } lowerNormalizeProtection(); if (lowerEventSuppressionAndTest()) { fireIntervalAdded(this, null, null); } }
public Passage trimVerses(int count) { optimizeWrites(); raiseNormalizeProtection(); int i = 0; boolean overflow = false; Passage remainder = this.clone(); for (Key verse : this) { i++; if (i > count) { remove(verse); overflow = true; } else { remainder.remove(verse); } } lowerNormalizeProtection(); // The event notification is done by the remove above if (overflow) { return remainder; } return null; }
public void retainAll(Key key) { optimizeWrites(); raiseEventSuppresion(); raiseNormalizeProtection(); Passage temp = this.clone(); for (Key verse : temp) { if (!key.contains(verse)) { remove(verse); } } lowerNormalizeProtection(); if (lowerEventSuppressionAndTest()) { fireIntervalRemoved(this, null, null); } }