final class ReadOnlyPassage extends Object implements Passage
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private boolean |
ignore
Do we just silently ignore change attempts or throw up
|
private Passage |
ref
The object we are proxying to
|
private static long |
serialVersionUID
Serialization ID
|
Constructor and Description |
---|
ReadOnlyPassage(Passage ref,
boolean ignore)
Construct a ReadOnlyPassage from a real Passage to which we proxy.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Key that)
Add this Verse/VerseRange to this Passage
|
void |
addAll(Key key)
Adds the specified element to this set if it is not already present.
|
void |
addPassageListener(PassageListener li)
Event Listeners - Add Listener
|
void |
blur(int by,
RestrictionType restrict)
Widen the range of the verses/keys in this list.
|
int |
booksInPassage()
How many books are there in this Passage
|
boolean |
canHaveChildren()
Returns false if the receiver is a leaf node and can not have children.
|
void |
clear()
Removes all of the elements from this set (optional operation).
|
ReadOnlyPassage |
clone()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
int |
compareTo(Key o) |
boolean |
contains(Key key)
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.
|
boolean |
equals(Object obj)
This needs to be declared here so that it is visible as a method on a
derived Key.
|
Key |
get(int index)
Gets a key from a specific point in this list of children.
|
int |
getCardinality()
Returns the number of elements in this set (its cardinality).
|
int |
getChildCount()
Returns the number of children that this node has.
|
String |
getName()
A Human readable version of the Key.
|
String |
getName(Key base)
Translate the Key into a human readable string, with the assumption that
the specified Key has just been output, so if we are in the same region,
we do not need to display the region name, and so on.
|
String |
getOsisID()
The OSIS defined id specification for this Key.
|
String |
getOsisRef()
The OSIS defined reference specification for this Key.
|
String |
getOverview()
A summary of the verses in this Passage For example
"10 verses in 4 books"
|
Key |
getParent()
All keys have parents unless they are the root of a Key.
|
VerseRange |
getRangeAt(int offset,
RestrictionType restrict)
Get a specific VerseRange from this collection
|
String |
getRootName()
A Human readable version of the Key's top level name.
|
Verse |
getVerseAt(int offset)
Get a specific Verse from this collection
|
Versification |
getVersification()
Get the Versification that defines the Verses in this VerseKey.
|
Passage |
getWhole()
Convert this reference into one without a sub-identifier.
|
int |
hashCode()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
boolean |
hasRanges(RestrictionType restrict)
Determine whether there are two or more ranges.
|
int |
indexOf(Key that)
Reverse a Key into the position the key holds in the list of children
|
boolean |
isEmpty()
Does this Key have 0 members
|
boolean |
isWhole()
A VerseKey that does not have an OSIS sub identifier is a whole reference.
|
Iterator<Key> |
iterator() |
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 |
removeAll(Key key)
Removes the specified elements from this set if it is present.
|
void |
removePassageListener(PassageListener li)
Event Listeners - Remove Listener
|
void |
retainAll(Key key)
Removes all but the specified element from this set.
|
Passage |
reversify(Versification newVersification)
Cast this VerseKey into another Versification.
|
String |
toString() |
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.
|
private Passage ref
private boolean ignore
private static final long serialVersionUID
ReadOnlyPassage(Passage ref, boolean ignore)
ref
- The real Passageignore
- Do we throw up if someone tries to change uspublic Versification getVersification()
VerseKey
getVersification
in interface VerseKey<Passage>
public Passage reversify(Versification newVersification)
VerseKey
Note: This is dangerous as it does not consider chapter boundaries or whether the verses in this VerseKey are actually part of the new versification. It should only be used when the start and end verses are in both Versifications. You have been warned.
public boolean isWhole()
VerseKey
public Passage getWhole()
VerseKey
public void addAll(Key key)
Key
public void removeAll(Key key)
Key
public void retainAll(Key key)
Key
public boolean contains(Key key)
Passage
public boolean canHaveChildren()
Key
canHaveChildren
in interface Key
public int getChildCount()
Key
getChildCount
in interface Key
public int getCardinality()
Key
This method is potentially expensive, as it often requires cycling through all the keys in the set.
getCardinality
in interface Key
public Key get(int index)
Key
public int indexOf(Key that)
Key
public Key getParent()
Key
public String getName()
Key
public String getName(Key base)
Key
public String getRootName()
Key
getRootName
in interface Key
public String getOsisRef()
Key
getOsisRef
in interface Key
public String getOsisID()
Key
public String getOverview()
Passage
getOverview
in interface Passage
public boolean isEmpty()
Key
public int countVerses()
Passage
countVerses
in interface Passage
Verse
public boolean hasRanges(RestrictionType restrict)
Passage
hasRanges
in interface Passage
restrict
- Do we break ranges at chapter/book boundariesVerseRange
public int countRanges(RestrictionType restrict)
Passage
countRanges
in interface Passage
restrict
- Do we break ranges at chapter/book boundariesVerseRange
public Passage trimVerses(int count)
Passage
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.trimVerses
in interface Passage
count
- The maximum number of Verses to allow in this collectionVerse
public Passage trimRanges(int count, RestrictionType restrict)
Passage
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.trimRanges
in interface Passage
count
- The maximum number of VerseRanges to allow in this collectionrestrict
- Do we break ranges at chapter/book boundariesVerseRange
public int booksInPassage()
Passage
booksInPassage
in interface Passage
public Verse getVerseAt(int offset) throws ArrayIndexOutOfBoundsException
Passage
getVerseAt
in interface Passage
offset
- The verse offset (legal values are 0 to countVerses()-1)ArrayIndexOutOfBoundsException
- If the offset is out of rangepublic VerseRange getRangeAt(int offset, RestrictionType restrict) throws ArrayIndexOutOfBoundsException
Passage
getRangeAt
in interface Passage
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 rangepublic Iterator<VerseRange> rangeIterator(RestrictionType restrict)
Passage
rangeIterator
in interface Passage
restrict
- Do we break ranges over chapterspublic void add(Key that)
Passage
public void remove(Key that)
Passage
public boolean containsAll(Passage that)
Passage
containsAll
in interface Passage
that
- Passage to be checked for containment in this collection.public void clear()
Key
public void blur(int by, RestrictionType restrict)
Key
public void readDescription(Reader in)
Passage
readDescription
in interface Passage
in
- The stream to read frompublic void writeDescription(Writer out) throws IOException
Passage
writeDescription
in interface Passage
out
- The stream to write toIOException
- If the file/network etc breakspublic void optimizeReads()
Passage
optimizeReads
in interface Passage
public void addPassageListener(PassageListener li)
Passage
addPassageListener
in interface Passage
li
- The listener to addpublic void removePassageListener(PassageListener li)
Passage
removePassageListener
in interface Passage
li
- The listener to removepublic boolean equals(Object obj)
Key
public int hashCode()
Key
public ReadOnlyPassage clone()
Key
public int compareTo(Key o)
compareTo
in interface Comparable<Key>