|
||||||||||
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 mis-translated in some way.
for license details.
The copyright to this program is held by it's authors.
Nested Class Summary | |
---|---|
private static class |
VerseRange.VerseIterator
Iterate over the Verses in the VerseRange |
Field Summary | |
---|---|
private Verse |
end
The real data - where do we end?. |
(package private) static Logger |
log
The log stream |
private String |
originalName
The original string for picky users |
private Key |
parent
The parent key. |
static String |
RANGE_ALLOWED_DELIMS
What characters can we use to separate the 2 parts to a VerseRanges |
static String |
RANGE_PREF_DELIM
What characters should we use to separate VerseRange parts |
(package private) static long |
serialVersionUID
To make serialization work across new versions |
private Verse |
start
The real data - where do we start?. |
private int |
verseCount
The real data - how many verses long are we?. |
private static VerseRange |
whole
The whole Bible VerseRange |
Constructor Summary | |
---|---|
VerseRange()
The default VerseRange is a single verse - Genesis 1:1. |
|
VerseRange(String original,
Verse start,
Verse end)
Construct a VerseRange from 2 Verses If start is later than end then swap the two around. |
|
VerseRange(Verse start)
Construct a VerseRange from a Verse. |
|
VerseRange(VerseRange a,
VerseRange b)
Merge 2 VerseRanges together. |
|
VerseRange(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 contigious. |
void |
blur(int by,
RestrictionType restrict)
Widen the range of the verses/keys in this list. |
private static Verse |
calcEnd(Verse start,
int verseCount)
Calculate the last verse in this range. |
private static int |
calcVerseCount(Verse start,
Verse end)
Calcualte how many verses in this range |
boolean |
canHaveChildren()
Returns true if the receiver is a leaf node and can not have children. |
void |
clear()
Removes all of the elements from this set (optional operation). |
Object |
clone()
This needs to be declared here so that it is visible as a method on a derived Key. |
int |
compareTo(Object 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. |
boolean |
equals(Object obj)
|
Key |
get(int index)
Gets a key from a specific point in this list. |
int |
getBookCount()
How many books in this range |
int |
getChapterCount()
How many chapters in this range |
int |
getChildCount()
Returns the number of elements in this set (its cardinality). |
Verse |
getEnd()
Fetch the last verse in this range. |
String |
getName()
Fetch a more sensible shortened version of the name |
String |
getName(Key base)
Fetch a more sensible shortened version of the name |
String |
getOsisID()
The OSIS defined id specification for this VerseRange. |
String |
getOsisRef()
The OSIS defined reference specification for this VerseRange. |
Key |
getParent()
All keys have parents unless they are the root of a Key. |
Verse |
getStart()
Fetch the first verse in this range. |
int |
getVerseCount()
How many verses in this range |
static VerseRange |
getWholeBibleVerseRange()
Returns a VerseRange that wraps the whole Bible |
int |
hashCode()
|
int |
indexOf(Key that)
Reverse a Key into the position the key holds in the list |
static VerseRange |
intersection(VerseRange a,
VerseRange b)
Create a DistinctPassage that is the stuff in VerseRange a that is also in VerseRange b. |
boolean |
isEmpty()
Does this Passage have 0 members |
boolean |
isMultipleBooks()
Does this range occupy more than one book; |
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 |
iterator()
|
boolean |
overlaps(VerseRange that)
Do the 2 VerseRanges in question actually overlap. |
Iterator |
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 DistinctPassage 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. |
void |
setParent(Key parent)
Set a parent Key. |
String |
toString()
This just clones getName which seems the most sensible type of string to return. |
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 String RANGE_ALLOWED_DELIMS
public static final String RANGE_PREF_DELIM
static final long serialVersionUID
private transient int verseCount
private transient Verse start
private transient Verse end
private transient Key parent
Key
private transient String originalName
private static transient VerseRange whole
static final transient Logger log
Constructor Detail |
---|
public VerseRange()
public VerseRange(Verse start)
start
- The verse to start frompublic VerseRange(Verse start, Verse end)
VerseRange(String original, Verse start, Verse end)
start
- The verse to start fromend
- The verse to end withpublic VerseRange(VerseRange a, VerseRange b)
a
- The first verse range to be mergedb
- The second verse range to be mergedMethod Detail |
---|
public String getName()
getName
in interface Key
public String getName(Key base)
getName
in interface Key
base
- A reference to allow things like Gen 1:1,3,5 as an output
public String getOsisRef()
getOsisRef
in interface Key
public String getOsisID()
getOsisID
in interface Key
public String toString()
toString
in class Object
public Verse getStart()
public Verse getEnd()
public int getVerseCount()
public int getChapterCount()
public int getBookCount()
public Object clone()
Key
clone
in interface Key
clone
in class Object
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(Object obj)
compareTo
in interface Comparable
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 rangeIterator(RestrictionType 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
- The verses that you might wantb
- The verses that you definately don't
public static VerseRange intersection(VerseRange a, VerseRange b)
a
- The verses that you might wantb
- The verses that you definately don't
public static VerseRange getWholeBibleVerseRange()
private static Verse calcEnd(Verse start, int verseCount)
start
- The first verse in the rangeverseCount
- The number of verses
private static int calcVerseCount(Verse start, Verse end)
start
- The first verse in the rangeend
- The last verse in the range
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 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 iterator()
iterator
in interface Iterable
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-2006 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |