public interface Passage extends VerseKey<Passage>
Passage no longer extends the Collection interface to avoid J2SE 1.1/1.2 portability problems, and because many of the things that a Passage does rely on consecutive Verses which are an alien concept to Collections. So users would have to use the Passage interface anyway.
Other arguments for and against.
The upshot of all this is that I am removing the Collections interface from Passage.
I considered giving Passages names to allow for a CLI that could use named RangedPassages, however that is perhaps better left to another class.
The GNU Lesser General Public License for details.
Modifier and Type | Method and Description |
---|---|
void |
add(Key that)
Add this Verse/VerseRange to this Passage
|
void |
addPassageListener(PassageListener li)
Event Listeners - Add Listener
|
int |
booksInPassage()
How many books are there in this Passage
|
boolean |
contains(Key that)
Returns true if this collection contains all the specified Verse
|
boolean |
containsAll(Passage that)
Returns true if this Passage contains all of the verses in that Passage
|
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.
|
String |
getOverview()
A summary of the verses in this Passage For example
"10 verses in 4 books"
|
VerseRange |
getRangeAt(int offset,
RestrictionType restrict)
Get a specific VerseRange from this collection
|
Verse |
getVerseAt(int offset)
Get a specific Verse from this collection
|
boolean |
hasRanges(RestrictionType restrict)
Determine whether there are two or more ranges.
|
void |
optimizeReads()
For performance reasons we may well want to hint to the Passage that we
have done editing it for now and that it is safe to cache certain values
to speed up future reads.
|
Iterator<VerseRange> |
rangeIterator(RestrictionType restrict)
Like iterator() that iterates over VerseRanges instead of Verses.
|
void |
readDescription(Reader in)
To be compatible with humans we read/write ourselves to a file that a
human can read and even edit.
|
void |
remove(Key that)
Remove this Verse/VerseRange from this Passage
|
void |
removePassageListener(PassageListener li)
Event Listeners - Remove Listener
|
Passage |
trimRanges(int count,
RestrictionType restrict)
Ensures that there are a maximum of
count VerseRanges in
this Passage. |
Passage |
trimVerses(int count)
Ensures that there are a maximum of
count Verses in this
Passage. |
void |
writeDescription(Writer out)
To be compatible with humans we read/write ourselves to a file that a
human can read and even edit.
|
getVersification, getWhole, isWhole, reversify
addAll, blur, canHaveChildren, clear, clone, equals, get, getCardinality, getChildCount, getName, getName, getOsisID, getOsisRef, getParent, getRootName, hashCode, indexOf, isEmpty, removeAll, retainAll
compareTo
String getOverview()
int countVerses()
Verse
boolean hasRanges(RestrictionType restrict)
restrict
- Do we break ranges at chapter/book boundariesVerseRange
int countRanges(RestrictionType restrict)
restrict
- Do we break ranges at chapter/book boundariesVerseRange
Passage trimVerses(int count)
count
Verses in this
Passage. If there were more than count
Verses then a new
Passage is created containing the Verses from count
+1
onwards. If there was not greater than count
in the Passage,
then the passage remains unchanged, and null is returned.count
- The maximum number of Verses to allow in this collectionVerse
Passage trimRanges(int count, RestrictionType restrict)
count
VerseRanges in
this Passage. If there were more than count
VerseRanges then
a new Passage is created containing the VerseRanges from
count
+1 onwards. If there was not greater than
count
in the Passage, then the passage remains unchanged,
and null is returned.count
- The maximum number of VerseRanges to allow in this collectionrestrict
- Do we break ranges at chapter/book boundariesVerseRange
int booksInPassage()
Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException
offset
- The verse offset (legal values are 0 to countVerses()-1)ArrayIndexOutOfBoundsException
- If the offset is out of rangeVerseRange getRangeAt(int offset, RestrictionType restrict) throws ArrayIndexOutOfBoundsException
offset
- The verse range offset (legal values are 0 to countRanges()-1)restrict
- Do we break ranges at chapter/book boundariesArrayIndexOutOfBoundsException
- If the offset is out of rangeIterator<VerseRange> rangeIterator(RestrictionType restrict)
restrict
- Do we break ranges over chaptersboolean contains(Key that)
void add(Key that)
that
- The Verses to be added from this Passagevoid remove(Key that)
that
- The Verses to be removed from this Passageboolean containsAll(Passage that)
that
- Passage to be checked for containment in this collection.void readDescription(Reader in) throws IOException, NoSuchVerseException
in
- The stream to read fromIOException
- If the file/network etc breaksNoSuchVerseException
- If the file was invalidvoid writeDescription(Writer out) throws IOException
out
- The stream to write toIOException
- If the file/network etc breaksvoid optimizeReads()
void addPassageListener(PassageListener li)
li
- The listener to addvoid removePassageListener(PassageListener li)
li
- The listener to remove