public class RangedPassage extends AbstractPassage
When to normalize()? This is a slow process, but one that is perhaps done bit-by-bit instead of killing everything just to do getName(). The options are:
The GNU Lesser General Public License for details.
,
Serialized FormModifier and Type | Class and Description |
---|---|
private static class |
RangedPassage.VerseIterator
This class is here to prevent users of RangedPassage.iterator() from
altering the underlying store and getting us out of sync.
|
private static class |
RangedPassage.VerseRangeIterator
Loop over the VerseRanges and check that they do not require digging into
|
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
To make serialization work across new versions
|
private Set<VerseRange> |
store
The place the real data is stored
|
BITWISE, DISTINCT, listeners, METHOD_COUNT, originalName, RANGED, REF_ALLOWED_DELIMS, REF_OSIS_DELIM, REF_PREF_DELIM, skipNormalization, suppressEvents
Modifier | Constructor and Description |
---|---|
|
RangedPassage(Versification refSystem)
Create an empty RangedPassage.
|
protected |
RangedPassage(Versification v11n,
String refs) |
protected |
RangedPassage(Versification v11n,
String refs,
Key basis)
Create a Verse from a human readable string.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Key obj)
Add this Verse/VerseRange to this Passage
|
void |
clear()
Removes all of the elements from this set (optional operation).
|
RangedPassage |
clone()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
boolean |
contains(Key obj)
Returns true if this collection contains all the specified Verse
|
int |
countRanges(RestrictionType restrict)
Like countVerses() that counts VerseRanges instead of Verses Returns the
number of fragments in this collection.
|
int |
countVerses()
Returns the number of verses in this collection.
|
boolean |
isEmpty()
Does this Key have 0 members
|
Iterator<Key> |
iterator() |
(package private) void |
normalize()
We sometimes need to sort ourselves out ...
|
Iterator<VerseRange> |
rangeIterator(RestrictionType restrict)
Like iterator() that iterates over VerseRanges instead of Verses.
|
private void |
readObject(ObjectInputStream in)
Call the support mechanism in AbstractPassage
|
void |
remove(Key obj)
Remove this Verse/VerseRange from this Passage
|
void |
retainAll(Key key)
Removes all but the specified element from this set.
|
private void |
writeObject(ObjectOutputStream out)
Call the support mechanism in AbstractPassage
|
addAll, addPassageListener, addVerses, blur, booksInPassage, canHaveChildren, compareTo, containsAll, equals, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, get, getCardinality, getChildCount, getName, getName, getOsisID, getOsisRef, getOverview, getParent, getRangeAt, getRootName, getVerseAt, getVersification, getWhole, hashCode, hasRanges, indexOf, isWhole, lowerEventSuppressionAndTest, lowerNormalizeProtection, optimizeReads, optimizeWrites, raiseEventSuppresion, raiseNormalizeProtection, readDescription, readObjectSupport, removeAll, removePassageListener, reversify, setParent, toString, toVerseRange, trimRanges, trimVerses, writeDescription, writeObjectSupport
private static final long serialVersionUID
private transient Set<VerseRange> store
public RangedPassage(Versification refSystem)
RangedPassage().add(...);
refSystem
- The Versification to which this Passage belongs.protected RangedPassage(Versification v11n, String refs, Key basis) throws NoSuchVerseException
RangedPassage v2 = new RangedPassage(v1.getName());
Then
v1.equals(v2);
Theoretically, since there are many ways of
representing a RangedPassage as text string comparison along the lines
of: v1.getName().equals(v2.getName())
could be false.
However since getName() is standardized this will be true. We don't need
to worry about thread safety in a ctor since we don't exist yet.v11n
- The Versification to which this Passage belongs.refs
- A String containing the text of the RangedPassagebasis
- The basis by which to interpret refsNoSuchVerseException
- if refs is invalidprotected RangedPassage(Versification v11n, String refs) throws NoSuchVerseException
NoSuchVerseException
public RangedPassage clone()
Key
clone
in interface Key
clone
in class AbstractPassage
public int countRanges(RestrictionType restrict)
Passage
countRanges
in interface Passage
countRanges
in class AbstractPassage
restrict
- Do we break ranges at chapter/book boundariesVerseRange
public int countVerses()
Passage
countVerses
in interface Passage
countVerses
in class AbstractPassage
Verse
public final Iterator<VerseRange> rangeIterator(RestrictionType restrict)
Passage
rangeIterator
in interface Passage
rangeIterator
in class AbstractPassage
restrict
- Do we break ranges over chapterspublic boolean isEmpty()
Key
isEmpty
in interface Key
isEmpty
in class AbstractPassage
public boolean contains(Key obj)
Passage
public void add(Key obj)
Passage
obj
- The Verses to be added from this Passagepublic void clear()
Key
clear
in interface Key
clear
in class AbstractPassage
public void remove(Key obj)
Passage
obj
- The Verses to be removed from this Passagepublic void retainAll(Key key)
Key
retainAll
in interface Key
retainAll
in class AbstractPassage
key
- object to be left in this set.final void normalize()
I don't think we need to be synchronized since we are private and we could check that all public calling of normalize() are synchronized, however this is safe, and I don't think there is a cost associated with a double synchronize. (?)
normalize
in class AbstractPassage
private void writeObject(ObjectOutputStream out) throws IOException
out
- The stream to write our state toIOException
- if the read failsAbstractPassage.writeObjectSupport(ObjectOutputStream)
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in
- The stream to read our state fromIOException
- if the read failsClassNotFoundException
- If the read data is incorrectAbstractPassage.readObjectSupport(ObjectInputStream)