public final class VerseRange extends Object implements VerseKey<VerseRange>
The GNU Lesser General Public License for details.
,
Serialized FormModifier and Type | Class and Description |
---|---|
private static class |
VerseRange.VerseIterator
Iterate over the Verses in the VerseRange
|
Modifier and Type | Field and Description |
---|---|
private Verse |
end
The last verse.
|
private String |
originalName
The original string for picky users
|
private Key |
parent
The parent key.
|
static char |
RANGE_OSIS_DELIM
What characters can we use to separate the 2 parts to a VerseRanges
|
static char |
RANGE_PREF_DELIM
What characters should we use to separate VerseRange parts on output
|
(package private) static long |
serialVersionUID
Serialization ID
|
private NumberShaper |
shaper
Allow the conversion to and from other number representations.
|
private Verse |
start
The start of the range
|
private Versification |
v11n
The Versification with which this range is defined.
|
private int |
verseCount
The number of verses in the range
|
Constructor and Description |
---|
VerseRange(VerseRange a,
VerseRange b)
Merge 2 VerseRanges together.
|
VerseRange(Versification v11n)
The default VerseRange is a single verse - Genesis 1:1.
|
VerseRange(Versification v11n,
Verse start)
Construct a VerseRange from a Verse.
|
VerseRange(Versification v11n,
Verse start,
Verse end) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Key key)
Adds the specified element to this set if it is not already present.
|
boolean |
adjacentTo(VerseRange that)
Are the 2 VerseRanges in question contiguous.
|
void |
blur(int by,
RestrictionType restrict)
Widen the range of the verses/keys in this list.
|
private Verse |
calcEnd()
Calculate the last verse in this range.
|
private int |
calcVerseCount()
Calculate how many verses in this range
|
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).
|
VerseRange |
clone()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
int |
compareTo(Key obj) |
boolean |
contains(Key key)
Returns true if this set contains the specified element.
|
boolean |
contains(Verse that)
Is the given verse entirely within our range.
|
boolean |
contains(VerseRange that)
Is the given range within our range.
|
private String |
doGetName(Key base) |
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.
|
Verse |
getEnd()
Fetch the last verse in this range.
|
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.
|
Key |
getParent()
All keys have parents unless they are the root of a Key.
|
String |
getRootName()
A Human readable version of the Key's top level name.
|
Verse |
getStart()
Fetch the first verse in this range.
|
Versification |
getVersification()
Get the Versification that defines the Verses in this VerseKey.
|
VerseRange |
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.
|
int |
indexOf(Key that)
Reverse a Key into the position the key holds in the list of children
|
static VerseRange |
intersection(VerseRange a,
VerseRange b)
Create a VerseRange that is the stuff in VerseRange a that is also
in VerseRange b.
|
boolean |
isEmpty()
Does this Key have 0 members
|
boolean |
isMultipleBooks()
Does this range occupy more than one book;
|
boolean |
isWhole()
A VerseKey that does not have an OSIS sub identifier is a whole reference.
|
boolean |
isWholeBook()
Does this range represent exactly one book, no more or less.
|
boolean |
isWholeBooks()
Does this range represent a whole number of books.
|
boolean |
isWholeChapter()
Does this range represent exactly one chapter, no more or less.
|
boolean |
isWholeChapters()
Does this range represent a number of whole chapters
|
Iterator<Key> |
iterator() |
boolean |
overlaps(VerseRange that)
Do the 2 VerseRanges in question actually overlap.
|
Iterator<VerseRange> |
rangeIterator(RestrictionType restrict)
Enumerate the subranges in this range
|
private void |
readObject(ObjectInputStream in)
Write out the object to the given ObjectOutputStream
|
static VerseRange[] |
remainder(VerseRange a,
VerseRange b)
Create a VerseRange that is the stuff left of VerseRange a when you
remove the stuff in VerseRange b.
|
void |
removeAll(Key key)
Removes the specified elements from this set if it is present.
|
void |
retainAll(Key key)
Removes all but the specified element from this set.
|
VerseRange |
reversify(Versification newVersification)
Cast this VerseKey into another Versification.
|
void |
setParent(Key parent)
Set a parent Key.
|
String |
toString() |
Verse[] |
toVerseArray()
Create an array of Verses
|
private void |
verifyData()
Check to see that everything is ok with the Data
|
private void |
writeObject(ObjectOutputStream out)
Write out the object to the given ObjectOutputStream
|
public static final char RANGE_OSIS_DELIM
public static final char RANGE_PREF_DELIM
private transient Versification v11n
private Verse start
private int verseCount
private transient Verse end
private transient NumberShaper shaper
private transient Key parent
private transient String originalName
static final long serialVersionUID
public VerseRange(Versification v11n)
v11n
- The versification for the rangepublic VerseRange(Versification v11n, Verse start)
v11n
- The versification for the rangestart
- The verse to start frompublic VerseRange(Versification v11n, Verse start, Verse end)
public VerseRange(VerseRange a, VerseRange b)
a
- The first verse range to be mergedb
- The second verse range to be mergedpublic Versification getVersification()
VerseKey
getVersification
in interface VerseKey<VerseRange>
public VerseRange 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.
reversify
in interface VerseKey<VerseRange>
public boolean isWhole()
VerseKey
isWhole
in interface VerseKey<VerseRange>
public VerseRange getWhole()
VerseKey
getWhole
in interface VerseKey<VerseRange>
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 Verse getStart()
public Verse getEnd()
public VerseRange clone()
Key
public boolean equals(Object obj)
Key
public int hashCode()
Key
public int compareTo(Key obj)
compareTo
in interface Comparable<Key>
public boolean adjacentTo(VerseRange that)
that
- The VerseRange to compare topublic boolean overlaps(VerseRange that)
that
- The VerseRange to compare topublic boolean contains(Verse that)
that
- The Verse to compare topublic boolean contains(VerseRange that)
that
- The Verse to compare topublic boolean contains(Key key)
Key
public boolean isWholeChapter()
public boolean isWholeChapters()
public boolean isWholeBook()
public boolean isWholeBooks()
public boolean isMultipleBooks()
public Verse[] toVerseArray()
public Iterator<VerseRange> rangeIterator(RestrictionType restrict)
restrict
- public Key getParent()
Key
public void setParent(Key parent)
parent
- The parent Key for this versepublic static VerseRange[] remainder(VerseRange a, VerseRange b)
a
- Verses at the start or end of bb
- All the versespublic static VerseRange intersection(VerseRange a, VerseRange b)
a
- The verses that you might wantb
- The verses that you definitely don'tprivate Verse calcEnd()
private int calcVerseCount()
private void verifyData()
private void writeObject(ObjectOutputStream out) throws IOException
out
- The stream to write our state toIOException
- If the write failsprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in
- The stream to read our state fromIOException
- If the write failsClassNotFoundException
- If the read data is incorrectpublic 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 boolean isEmpty()
Key
public void addAll(Key key)
Key
public void removeAll(Key key)
Key
public void retainAll(Key key)
Key
public void clear()
Key
public Key get(int index)
Key
public int indexOf(Key that)
Key
public void blur(int by, RestrictionType restrict)
Key