|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.eireneh.bible.passage
Class VerseRange

java.lang.Objectcom.eireneh.bible.passage.VerseRange
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Comparable, PassageConstants, java.io.Serializable, VerseBase
- public class VerseRange
- extends java.lang.Object
- implements VerseBase
- extends java.lang.Object
A VerseRange is one step between a Verse and a Passage - it is a Verse plus a verse_count. Every VerseRange has a start, a verse_count 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.
|
Distribution Licence: Project B is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The License is available on the internet here, by writing to Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, Or locally at the Licence link below. The copyright to this program is held by it's authors. |
- Version:
- D9.I9.T7
| Field Summary | |
private Verse |
end
The real data - where do we end? All ctors init this so leave default |
protected static com.eireneh.util.Logger |
log
The log stream |
private java.lang.String |
original_name
The original string for picky users |
(package private) static long |
serialVersionUID
To make serialization work across new versions |
private Verse |
start
The real data - where do we start? All ctors init this so leave default |
private int |
verse_count
The real data - how many verses long are we? All ctors init this so leave default |
private static VerseRange |
whole
The whole Bible VerseRange |
| Fields inherited from interface com.eireneh.bible.passage.PassageConstants |
ACCURACY_BOOK_CHAPTER, ACCURACY_BOOK_ONLY, ACCURACY_BOOK_VERSE, ACCURACY_CHAPTER_VERSE, ACCURACY_NONE, ACCURACY_VERSE_ONLY, CASE_LOWER, CASE_MIXED, CASE_SENTANCE, CASE_UPPER, CASES, RANGE_ALLOWED_DELIMS, RANGE_PREF_DELIM, REF_ALLOWED_DELIMS, REF_PREF_DELIM, RESTRICT_BOOK, RESTRICT_CHAPTER, RESTRICT_NONE, RESTRICTIONS, VERSE_ALLOWED_DELIMS, VERSE_END_MARK1, VERSE_END_MARK2, VERSE_NUMERIC_BOOK, VERSE_PREF_DELIM1, VERSE_PREF_DELIM2 |
| Constructor Summary | |
VerseRange()
The default VerseRange is a single verse - Genesis 1:1. |
|
VerseRange(java.lang.String desc)
Construct a VerseRange from a human readable string. |
|
VerseRange(java.lang.String desc,
Verse basis)
Construct a VerseRange from a String and a Verse. |
|
VerseRange(java.lang.String desc,
VerseRange basis)
Construct a VerseRange from a String and a VerseRange. |
|
VerseRange(Verse start)
Construct a VerseRange from a Verse. |
|
VerseRange(Verse start,
int verse_count)
Construct a VerseRange from a Verse and a range. |
|
VerseRange(Verse start,
int verse_count,
boolean patch_up)
Construct a VerseRange from a Verse and a range. |
|
VerseRange(Verse base_start,
int blur_down,
int blur_up,
int restrict)
Widen the range of the verses in this list. |
|
VerseRange(VerseRange base_start,
int blur_down,
int blur_up,
int restrict)
Widen the range of the verses in this list. |
|
VerseRange(VerseRange a,
VerseRange b)
Merge 2 VerseRanges together. |
|
VerseRange(Verse start,
Verse end)
Construct a VerseRange from 2 Verses If start is later than end then swap the two around. |
|
| Method Summary | |
boolean |
adjacentTo(VerseRange that)
Are the 2 VerseRanges in question contigious. |
private static Verse |
calcEnd(Verse start,
int verse_count)
Calculate the last verse in this range. |
private static int |
calcVerseCount(Verse start,
Verse end)
Calcualte how many verses in this range |
java.lang.Object |
clone()
Get a copy of ourselves. |
int |
compareTo(java.lang.Object obj)
Compare initially using the first element in a VerseRange. |
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(java.lang.Object obj)
Is this Object equal to us. |
Verse |
getEnd()
Fetch the last verse in this range. |
java.lang.String |
getName()
Fetch a more sensible shortened version of the name |
java.lang.String |
getName(Verse base)
Fetch a more sensible shortened version of the name |
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()
The hashing number is currently calculated using the start ordinal in the upper 16 bits, and the verse_count in the lower. |
static VerseRange |
intersection(VerseRange a,
VerseRange b)
Create a DistinctPassage that is the stuff in VerseRange a that is also in VerseRange b. |
boolean |
isBook()
Does this range represent exactly one book, no more or less. |
boolean |
isBooks()
Does this range represent a whole number of books. |
boolean |
isChapter()
Does this range represent exactly one chapter, no more or less. |
boolean |
isChapters()
Does this range represent a number of whole chapters |
static boolean |
isVerseRange(java.lang.String desc)
Is the string likely to be a VerseRange and not a Verse? |
boolean |
overlaps(VerseRange that)
Do the 2 VerseRanges in question actually overlap. |
private void |
readObject(java.io.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. |
java.lang.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 |
java.util.Enumeration |
verseElements()
Enumerate over the verse in this range |
private void |
writeObject(java.io.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 |
serialVersionUID
static final long serialVersionUID
- To make serialization work across new versions
- See Also:
- Constant Field Values
verse_count
private transient int verse_count
- The real data - how many verses long are we? All ctors init this so leave default
start
private transient Verse start
- The real data - where do we start? All ctors init this so leave default
end
private transient Verse end
- The real data - where do we end? All ctors init this so leave default
original_name
private transient java.lang.String original_name
- The original string for picky users
whole
private static transient VerseRange whole
- The whole Bible VerseRange
log
protected static transient com.eireneh.util.Logger log
- The log stream
| Constructor Detail |
VerseRange
public VerseRange()
- The default VerseRange is a single verse - Genesis 1:1. I didn't
want to provide this constructor however, you are supposed to
provide a default ctor for all beans. For this reason I suggest you
don't use it.
VerseRange
public VerseRange(java.lang.String desc) throws NoSuchVerseException
- Construct a VerseRange from a human readable string. For example
"Gen 1:1-3" in case the user does not want to have their typing
'fixed' by a meddling patronizing computer.
VerseRange
public VerseRange(java.lang.String desc, Verse basis) throws NoSuchVerseException
- Construct a VerseRange from a String and a Verse. For example given
"2:2" and a basis of Gen 1:1 the result would be range of 1 verse
starting at Gen 2:2. Also given "2:2-5" and a basis of Gen 1:1 the
result would be a range of 5 verses starting at Gen 1:1.
VerseRange
public VerseRange(java.lang.String desc, VerseRange basis) throws NoSuchVerseException
- Construct a VerseRange from a String and a VerseRange. For example given "2:2"
and a basis of Gen 1:1-2 the result would be range of 1 verse starting at
Gen 2:2. Also given "2:2-5" and a basis of Gen 1:1-2 the result would be a
range of 5 verses starting at Gen 1:1.
This constructor is different from the (String, Verse) constructor in that if the basis is a range that exactly covers a chapter and the string is a single number, then we assume that the number referrs to a chapter and not to a verse. This allows us to have a Passage like "Gen 1,2" and have the 2 understood as chapter 2 and not verse 2 of Gen 1, which would have occured otherwise.
VerseRange
public VerseRange(Verse start)
- Construct a VerseRange from a Verse. The resultant VerseRange will be
1 verse in verse_count.
VerseRange
public VerseRange(Verse start, int verse_count) throws NoSuchVerseException
- Construct a VerseRange from a Verse and a range.
VerseRange
public VerseRange(Verse start, int verse_count, boolean patch_up)
- Construct a VerseRange from a Verse and a range.
Now the actual value of the boolean is ignored. However for future proofing
you should only use 'true'. Do not use patch_up=false, use Verse(int, int, int)
This so that we can declare this constructor to not throw an exception.
Is there a better way of doing this?
VerseRange
public VerseRange(Verse start, Verse end)
- Construct a VerseRange from 2 Verses
If start is later than end then swap the two around.
VerseRange
public VerseRange(Verse base_start, int blur_down, int blur_up, int restrict)
- Widen the range of the verses in this list. This is primarily for
"find x within n verses of y" type applications.
VerseRange
public VerseRange(VerseRange base_start, int blur_down, int blur_up, int restrict)
- Widen the range of the verses in this list. This is primarily for
"find x within n verses of y" type applications.
VerseRange
public VerseRange(VerseRange a, VerseRange b)
- Merge 2 VerseRanges together. The resulting range will encompass
Everying in-between the extremities of the 2 ranges.
| Method Detail |
getName
public java.lang.String getName()
getName
public java.lang.String getName(Verse base)
toString
public java.lang.String toString()
- This just clones getName which seems the most sensible
type of string to return.
getStart
public Verse getStart()
- Fetch the first verse in this range.
getEnd
public Verse getEnd()
- Fetch the last verse in this range.
getVerseCount
public int getVerseCount()
- How many verses in this range
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Get a copy of ourselves. Points to note:
Call clone() not new() on member Objects, and on us.
Do not use Copy Constructors! - they do not inherit well.
Think about this needing to be synchronized
If this is not cloneable then writing cloneable children is harder
equals
public boolean equals(java.lang.Object obj)
- Is this Object equal to us. Points to note:
If you override equals(), you must override hashCode() too.
If you are doing this it is a good idea to be immutable.
hashCode
public int hashCode()
- The hashing number is currently calculated using the start ordinal
in the upper 16 bits, and the verse_count in the lower.
Note that this may change and should not be relied upon Use getStart().getOrdinal() and so on to get that kind of info.
The news from this however is that sorting by hashCode() is currently the same as sorting using compareTo().
compareTo
public int compareTo(java.lang.Object obj)
- Compare initially using the first element in a VerseRange. If the
starting verses are the same then sort according to length, shortest
first so:
Gen 1:1 < Gen 1:1-2 < Gen 1:1-26 < Gen 1:2
Note that this compares Verse("Gen 1:1") = VerseRange("Gen 1:1") I'm not sure if this is 100% pucka, but it doesn't seem to cause any problems.
- Specified by:
compareToin interfacejava.lang.Comparable
adjacentTo
public boolean adjacentTo(VerseRange that)
- Are the 2 VerseRanges in question contigious. ie - could they be
represented by a single VerseRange. Note that one range could be
entirely contained within the other and they would be considered
adjacentTo()
For example Gen 1:1-2 is adjacent to Gen 1:1-5 and Gen 1:3-4 but
not to Gen 1:4-10. Also Gen 1:29-30 is adjacent to Gen 2:1-10
overlaps
public boolean overlaps(VerseRange that)
- Do the 2 VerseRanges in question actually overlap. This is slightly
more restrictive than the adjacentTo() test which could be satisfied by
ranges like Gen 1:1-2 and Gen 1:3-4. overlaps() however would return
false given these ranges.
For example Gen 1:1-2 is adjacent to Gen 1:1-5 but not to Gen 1:3-4
not to Gen 1:4-10. Also Gen 1:29-30 does not overlap Gen 2:1-10
contains
public boolean contains(Verse that)
- Is the given verse entirely within our range.
For example if this = "Gen 1:1-31" then:
contains(Verse("Gen 1:3")) == true
contains(Verse("Gen 2:1")) == false
contains
public boolean contains(VerseRange that)
- Is the given range within our range.
For example if this = "Gen 1:1-31" then:
this.contains(Verse("Gen 1:3-10")) == true
this.contains(Verse("Gen 2:1-1")) == false
isChapter
public boolean isChapter()
- Does this range represent exactly one chapter, no more or less.
isChapters
public boolean isChapters()
- Does this range represent a number of whole chapters
isBook
public boolean isBook()
- Does this range represent exactly one book, no more or less.
isBooks
public boolean isBooks()
- Does this range represent a whole number of books.
toVerseArray
public Verse[] toVerseArray()
- Create an array of Verses
- Specified by:
toVerseArrayin interfaceVerseBase
verseElements
public java.util.Enumeration verseElements()
- Enumerate over the verse in this range
- Specified by:
verseElementsin interfaceVerseBase
remainder
public 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.
intersection
public static VerseRange intersection(VerseRange a, VerseRange b)
- Create a DistinctPassage that is the stuff in VerseRange a
that is also in VerseRange b.
isVerseRange
public static boolean isVerseRange(java.lang.String desc)
- Is the string likely to be a VerseRange and not a Verse?
getWholeBibleVerseRange
public static VerseRange getWholeBibleVerseRange()
- Returns a VerseRange that wraps the whole Bible
calcEnd
private static final Verse calcEnd(Verse start, int verse_count)
- Calculate the last verse in this range.
calcVerseCount
private static final int calcVerseCount(Verse start, Verse end)
- Calcualte how many verses in this range
verifyData
private void verifyData()
- Check to see that everything is ok with the Data
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- Write out the object to the given ObjectOutputStream
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Write out the object to the given ObjectOutputStream
|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.eireneh.bible.passage.VerseRange