public class Versification extends Object implements ReferenceSystem, Serializable
The GNU Lesser General Public License for details.
,
Serialized FormModifier and Type | Field and Description |
---|---|
private BibleBookList |
bookList
The ordered list of books in this versification.
|
private int[][] |
chapterStarts
Constant for the ordinal number of the first verse in each chapter.
|
private int[][] |
lastVerse
Constant for the max verse number in each chapter
|
private String |
name
The OSIS name of the reference system.
|
private int |
ntMaxOrdinal
The last ordinal number of the New Testament and the maximum ordinal number of this Reference System
|
private int |
otMaxOrdinal
The last ordinal number of the Old Testament
|
private static long |
serialVersionUID
Serialization ID
|
Constructor and Description |
---|
Versification() |
Versification(String name,
BibleBook[] booksOT,
BibleBook[] booksNT,
int[][] lastVerseOT,
int[][] lastVerseNT)
Construct a Versification.
|
Modifier and Type | Method and Description |
---|---|
Verse |
add(Verse verse,
int n)
Get the verse that is a few verses on from the one we've got.
|
boolean |
containsBook(BibleBook book)
Does this Versification contain the BibleBook.
|
Verse |
decodeOrdinal(int ordinal)
Where does this verse come in the Bible.
|
int |
distance(Verse start,
Verse end)
How many verses are there in between the 2 Verses.
|
static void |
dump(PrintStream out,
String name,
BibleBookList bookList,
int[][] array) |
VerseRange |
getAllVerses()
Get a VerseRange encompassing this Versification.
|
BibleBook |
getBook(int ordinal)
Get the BibleBook by its position in this Versification.
|
BibleBook |
getBook(String find)
Get a book from its name.
|
int |
getBookCount()
Get the number of books in this Versification.
|
int |
getBookCount(Verse start,
Verse end)
The number of books between two verses includes
the books of the two verses and everything in between.
|
Iterator<BibleBook> |
getBookIterator()
Get the BibleBooks in this Versification.
|
BookName |
getBookName(BibleBook book)
Get the BookName.
|
int |
getChapterCount(Verse start,
Verse end)
The number of chapters between two verses includes
the chapters of the two verses and everything in between.
|
int |
getCount(Testament testament)
Give the count of verses in the testament or the whole Bible.
|
BibleBook |
getFirstBook()
Return the first book in the list.
|
BibleBook |
getLastBook()
Return the first book in the list.
|
int |
getLastChapter(BibleBook book)
Get the last valid chapter number for a book.
|
int |
getLastVerse(BibleBook book,
int chapter)
Get the last valid verse number for a chapter.
|
String |
getLongName(BibleBook book)
Get the full name of a book (e.g.
|
String |
getName()
Get the OSIS name for this Versification.
|
BibleBook |
getNextBook(BibleBook book)
Given a BibleBook, get the next BibleBook in this Versification.
|
int |
getOrdinal(Testament testament,
int testamentOrdinal)
Determine the ordinal value for this versification given the
ordinal value in a testament.
|
int |
getOrdinal(Verse verse)
Where does this verse come in the Bible.
|
String |
getPreferredName(BibleBook book)
Get the preferred name of a book.
|
BibleBook |
getPreviousBook(BibleBook book)
Given a BibleBook, get the previous BibleBook in this Versification.
|
String |
getShortName(BibleBook book)
Get the short name of a book (e.g.
|
Testament |
getTestament(int ordinal)
Get the testament of a given verse
|
int |
getTestamentOrdinal(int ordinal)
Where does this verse come in the Bible.
|
boolean |
isAdjacentBook(Verse first,
Verse second)
Two verses are in adjacent books if one book
follows the other in this versification.
|
boolean |
isAdjacentChapter(Verse first,
Verse second)
Two verse are adjacent if one immediately follows the other,
even across book boundaries.
|
boolean |
isAdjacentVerse(Verse first,
Verse second)
Is this verse adjacent to another verse
|
boolean |
isBook(String find)
Is the given string a valid book name.
|
boolean |
isBookIntro(Verse verse)
A book introduction is an introduction
that has a chapter of 0.
|
boolean |
isChapterIntro(Verse verse)
A chapter introduction is an introduction
that has a chapter other than 0
|
boolean |
isEndOfBook(Verse verse)
The end of the book is indicated by
the chapter number matching the last chapter
in the book and the verse number matching
the last verse in the chapter.
|
boolean |
isEndOfChapter(Verse verse)
The end of the chapter is indicated by
the verse number matching the last in the chapter.
|
boolean |
isIntro(Verse verse)
An introduction is a Verse that has a verse number of 0.
|
boolean |
isSameBook(Verse first,
Verse second)
Two verses are in the same book
when they have the same book.
|
boolean |
isSameChapter(Verse first,
Verse second)
Two verses are in the same chapter if both
the book and chapter agree.
|
boolean |
isStartOfBook(Verse verse)
The start of a book is indicated by
a chapter number of 0 or 1 and
a verse number of 0 or 1.
|
boolean |
isStartOfChapter(Verse verse)
The start of a chapter is indicated by
a verse number of 0 or 1
|
Verse |
max(Verse first,
Verse second)
Determine the later of the two verses.
|
int |
maximumOrdinal()
The maximum number of verses in the Bible, including module, testament, book and chapter introductions.
|
Verse |
min(Verse first,
Verse second)
Determine the earlier of the two verses.
|
Verse |
next(Verse verse)
Get the verse that is a verses on from the one we've got.
|
static void |
optimize(PrintStream out,
BibleBookList bookList,
int[][] lastVerse) |
Verse |
patch(BibleBook book,
int chapter,
int verse)
Fix up these verses so that they are as valid a possible.
|
Verse |
subtract(Verse verse,
int n)
Get the verse n down from here this Verse.
|
void |
validate(BibleBook book,
int chapter,
int verse)
Does the following represent a real verse?.
|
boolean |
validate(BibleBook book,
int chapter,
int verse,
boolean silent)
Does the following represent a real verse?.
|
private String name
private BibleBookList bookList
private int otMaxOrdinal
private int ntMaxOrdinal
private int[][] lastVerse
private int[][] chapterStarts
private static final long serialVersionUID
public Versification()
public Versification(String name, BibleBook[] booksOT, BibleBook[] booksNT, int[][] lastVerseOT, int[][] lastVerseNT)
name
- The name of this reference systembooksOT
- An ordered list of books in this reference system. The list
should not include INTRO_BIBLE, or INTRO_OT.booksNT
- An ordered list of books in this reference system. The list
should not include INTRO_NT.lastVerseOT
- For each book in booksOT, this has an array with one entry for
each chapter whose value is the highest numbered verse in that
chapter. Do not include chapter 0.lastVerseNT
- For each book in booksNT, this has an array with one entry for
each chapter whose value is the highest numbered verse in that
chapter. Do not include chapter 0.public String getName()
public boolean containsBook(BibleBook book)
book
- public BibleBook getBook(int ordinal)
ordinal
- public BibleBook getBook(String find)
find
- The string to identifypublic int getBookCount()
public int getBookCount(Verse start, Verse end)
start
- The first Verse in the rangeend
- The last Verse in the rangepublic BibleBook getFirstBook()
public BibleBook getLastBook()
public BibleBook getNextBook(BibleBook book)
book
- A BibleBook in the Versificationpublic BibleBook getPreviousBook(BibleBook book)
book
- A BibleBook in the Versificationpublic Iterator<BibleBook> getBookIterator()
public BookName getBookName(BibleBook book)
book
- the desired bookpublic String getPreferredName(BibleBook book)
book
- the desired bookpublic String getLongName(BibleBook book)
book
- the book of the Biblepublic String getShortName(BibleBook book)
book
- the book of the Biblepublic boolean isBook(String find)
find
- The string to identifypublic int getLastChapter(BibleBook book)
book
- The book part of the reference.public int getLastVerse(BibleBook book, int chapter)
book
- The book part of the reference.chapter
- The current chapterpublic VerseRange getAllVerses()
public boolean isIntro(Verse verse)
verse
- the verse to testpublic boolean isBookIntro(Verse verse)
verse
- the verse to testpublic boolean isChapterIntro(Verse verse)
verse
- the verse to testpublic boolean isStartOfChapter(Verse verse)
verse
- the verse to testpublic boolean isEndOfChapter(Verse verse)
verse
- the verse to testpublic boolean isStartOfBook(Verse verse)
verse
- the verse to testpublic boolean isEndOfBook(Verse verse)
verse
- the verse to testpublic boolean isSameChapter(Verse first, Verse second)
first
- The verse to compare tosecond
- The verse to compare topublic boolean isAdjacentChapter(Verse first, Verse second)
first
- The verse to compare tosecond
- The verse to compare topublic boolean isSameBook(Verse first, Verse second)
first
- The verse to compare tosecond
- The verse to compare topublic boolean isAdjacentBook(Verse first, Verse second)
first
- The verse to compare tosecond
- The verse to compare topublic boolean isAdjacentVerse(Verse first, Verse second)
first
- The first verse in the comparisonsecond
- The second verse in the comparisonpublic int distance(Verse start, Verse end)
distance(gen11, gen12) == 1
start
- The first Verse in the rangeend
- The last Verse in the rangepublic Verse min(Verse first, Verse second)
first
- the first verse to comparesecond
- the second verse to comparepublic Verse max(Verse first, Verse second)
first
- the first verse to comparesecond
- the second verse to comparepublic Verse subtract(Verse verse, int n)
verse
- The verse to use as a startn
- The number to count down bypublic Verse next(Verse verse)
verse
- The verse to use as a startpublic Verse add(Verse verse, int n)
verse
- The verse to use as a startn
- the number of verses later than the one we're onepublic int getChapterCount(Verse start, Verse end)
start
- The first Verse in the rangeend
- The last Verse in the rangepublic int maximumOrdinal()
public int getOrdinal(Verse verse)
verse
- The verse to convertpublic int getOrdinal(Testament testament, int testamentOrdinal)
testament
- the testament in which the ordinal value pertainstestamentOrdinal
- the ordinal value within the testamentpublic int getTestamentOrdinal(int ordinal)
ordinal
- The ordinal number of the verse to convertpublic Testament getTestament(int ordinal)
ordinal
- the ordinal position of the verse in the whole Biblepublic int getCount(Testament testament)
testament
- The testament to count. If null, then all testaments.public Verse decodeOrdinal(int ordinal)
ordinal
- The ordinal number of the versepublic void validate(BibleBook book, int chapter, int verse) throws NoSuchVerseException
book
- The book part of the reference.chapter
- The chapter part of the reference.verse
- The verse part of the reference.NoSuchVerseException
- If the reference is illegalpublic boolean validate(BibleBook book, int chapter, int verse, boolean silent) throws NoSuchVerseException
book
- The book part of the reference.chapter
- The chapter part of the reference.verse
- The verse part of the reference.silent
- true to indicate we do not want to throw an exceptionNoSuchVerseException
- If the reference is illegal and silent was falsepublic Verse patch(BibleBook book, int chapter, int verse)
There is another patch system that allows us to use large numbers to mean "the end of" so "Gen 1:32".otherPatch() gives "Gen 1:31". This could be useful to allow the user to enter things like "Gen 1:99" meaning the end of the chapter. Or "Isa 99:1" to mean the last chapter in Isaiah verse 1 or even "Rev 99:99" to mean the last verse in the Bible.
However I have not implemented this because I've used a different convention: "Gen 1:$" (OLB compatible) or "Gen 1:ff" (common commentary usage) to mean the end of the chapter - So the functionality is there anyway.
I think that getting into the habit of typing "Gen 1:99" is bad. It could be the source of surprises "Psa 119:99" is not what you'd might expect, and neither is "Psa 99:1" is you wanted the last chapter in Psalms - expecting us to type "Psa 999:1" seems like we're getting silly.
However despite this maybe we should provide the functionality anyway.
book
- the book to obtainchapter
- the supposed chapterverse
- the supposed versepublic static void dump(PrintStream out, String name, BibleBookList bookList, int[][] array)
public static void optimize(PrintStream out, BibleBookList bookList, int[][] lastVerse)