|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.jsword.passage.VerseRange
public final class VerseRange
A VerseRange is one step between a Verse and a Passage - it is a Verse plus a verseCount. Every VerseRange has a start, a verseCount and an end. A VerseRange is designed to be immutable. This is a necessary from a collections point of view. A VerseRange should always be valid, although some versions may not return any text for verses that they consider to be miss-translated in some way.
The GNU Lesser General Public License for details.
,
Serialized FormNested Class Summary | |
---|---|
private static class |
VerseRange.VerseIterator
Iterate over the Verses in the VerseRange |
Field Summary | |
---|---|
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 Summary | |
---|---|
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)
|
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
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 mergedMethod Detail |
---|
public 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
getName
in interface Key
public String getName(Key base)
Key
getName
in interface Key
base
- The key to use to cut down unnecessary output.
public String getRootName()
Key
getRootName
in interface Key
public String getOsisRef()
Key
getOsisRef
in interface Key
public String getOsisID()
Key
getOsisID
in interface Key
public String toString()
toString
in class Object
public Verse getStart()
public Verse getEnd()
public VerseRange clone()
Key
clone
in interface Key
clone
in class Object
public boolean equals(Object obj)
Key
equals
in interface Key
equals
in class Object
public int hashCode()
Key
hashCode
in interface Key
hashCode
in class Object
public int compareTo(Key obj)
compareTo
in interface Comparable<Key>
public boolean adjacentTo(VerseRange that)
that
- The VerseRange to compare to
public boolean overlaps(VerseRange that)
that
- The VerseRange to compare to
public boolean contains(Verse that)
that
- The Verse to compare to
public boolean contains(VerseRange that)
that
- The Verse to compare to
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
getParent
in interface 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 verses
public static VerseRange intersection(VerseRange a, VerseRange b)
a
- The verses that you might wantb
- The verses that you definitely don't
private String doGetName(Key base)
private Verse calcEnd()
private int calcVerseCount()
private void verifyData()
private void writeObject(ObjectOutputStream out) throws IOException
out
- The stream to write our state to
IOException
- If the write failsprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in
- The stream to read our state from
IOException
- If the write fails
ClassNotFoundException
- 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
isEmpty
in interface Key
public boolean contains(Key key)
Key
contains
in interface Key
key
- element whose presence in this set is to be tested.
public Iterator<Key> iterator()
iterator
in interface Iterable<Key>
public void addAll(Key key)
Key
addAll
in interface Key
key
- element to be added to this set.public void removeAll(Key key)
Key
removeAll
in interface Key
key
- object to be removed from this set, if present.public void retainAll(Key key)
Key
retainAll
in interface Key
key
- object to be left in this set.public void clear()
Key
clear
in interface Key
public Key get(int index)
Key
get
in interface Key
index
- The index of the Key to retrieve
public int indexOf(Key that)
Key
indexOf
in interface Key
that
- The Key to find
public void blur(int by, RestrictionType restrict)
Key
blur
in interface Key
by
- The number of verses/keys to widen byrestrict
- How should we restrict the blurring?Passage
|
Copyright ยจ 2003-2015 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |