|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.crosswire.jsword.passage.BibleInfo
public final class BibleInfo
BibleInfo is a static class that deals with Book number conversions and similar. We start counting at 1 for books, chapters and verses (so Genesis=1, Revelation=66). However internally books start counting at 0 and go up to 65.
I've considered merging BibleInfo and PassageUtil since they are both supporting static only classes. However they are both non-trivial, so together they would be large, and there is a good dividing line between the 2.
for license details.
The copyright to this program is held by it's authors.| Nested Class Summary | |
|---|---|
static class |
BibleInfo.Names
Handy book finder |
static class |
BibleInfo.Section
Handy section finder. |
| Field Summary | |
|---|---|
private static String |
ALT_KEY
|
private static String[][] |
altBooksLower
Alternative shortened names for the book of the Bible, in lower case |
private static Map |
altBooksMap
Alternative shortened names for the book of the Bible, in lower case, generated at run time |
static int |
BOOK
Used for methods with int[3] parameters, for the book |
private static CaseType |
bookCase
How the book names are reported. |
private static int |
BOOKS_IN_BIBLE
Constant for the number of books in the Bible |
(package private) static short[] |
BOOKS_IN_SECTION
The number of books in each section |
static int |
CHAPTER
Used for methods with int[3] parameters, for the chapter |
private static int |
CHAPTERS_IN_BIBLE
Constant for the number of chapters in the Bible |
(package private) static short[] |
CHAPTERS_IN_BOOK
Constant for the number of chapters in each book |
private static String |
FULL_KEY
|
private static boolean |
fullBookName
Whether long or short, full or abbreviated names are used. |
private static String[] |
fullBooks
The full names of the book of the Bible, in mixed case |
private static String[] |
fullBooksLower
The full names of the book of the Bible, in lower case, generated at run time |
private static String[] |
fullBooksUpper
The full names of the book of the Bible, in upper case, generated at run time |
protected static BibleInfo |
instance
A singleton used to do initialization. |
(package private) static short[] |
ORDINAL_AT_START_OF_BOOK
Constant for the ordinal number of the first verse in each book |
(package private) static short[][] |
ORDINAL_AT_START_OF_CHAPTER
Constant for the ordinal number of the first verse in each chapter. |
private static String |
OSIS_KEY
|
private static String |
OSIS_PROPERTIES
|
private static String[] |
osisBooks
Standard OSIS names for the book of the Bible, in mixed case |
private static Map |
osisMap
Standard OSIS names for the book of the Bible, in mixed case |
private static String |
SECTION_KEY
|
private static String[] |
sections
Standard names for the sections |
private static int |
SECTIONS_IN_BIBLE
Constant for the number of sections in the Bible |
private static String[] |
sectionsLower
Standard Bible section names, in lower case, generated at run time |
private static String[] |
sectionsUpper
Standard Bible section names, in upper case, generated at run time |
private static String |
SHORT_KEY
|
private static String[] |
shortBooks
Standard shortened names for the book of the Bible, in mixed case |
private static String[] |
shortBooksLower
Standard shortened names for the book of the Bible, in lower case, generated at run time |
private static Map |
shortBooksMap
Standard shortened names for the book of the Bible, in lower case, generated at runtime. |
private static String[] |
shortBooksUpper
Standard shortened names for the book of the Bible, in upper case, generated at run time |
static int |
VERSE
Used for methods with int[3] parameters, for the verse |
(package private) static short |
VERSES_IN_BIBLE
Constant for the number of verses in the Bible |
(package private) static short[] |
VERSES_IN_BOOK
Constant for the number of verses in each book |
(package private) static short[][] |
VERSES_IN_CHAPTER
Constant for the number of verses in each chapter |
| Constructor Summary | |
|---|---|
private |
BibleInfo()
Ensure that we can not be instantiated |
| Method Summary | |
|---|---|
static int |
booksInBible()
Count the books in the Bible. |
static int |
booksInSection(int section)
How many books are there in each of the above sections |
static int |
chaptersInBible()
Count the chapters in the Bible. |
static int |
chaptersInBook(int book)
Count the chapters in this book. |
protected static boolean |
containsLetter(String text)
This is simply a convenience function to wrap Character.isLetter() |
static int[] |
decodeOrdinal(int ordinal)
Where does this verse come in the Bible. |
static String |
getBookName(int book)
Get the preferred name of a book. |
static int |
getBookNumber(String find)
Get number of a book from its name. |
static int |
getCase()
This is only used by config |
static CaseType |
getDefaultCase()
How do we report the names of the books?. |
static String |
getLongBookName(int book)
Get the full name of a book (e.g. |
static String |
getOSISName(int book)
Get the OSIS name for a book. |
static int |
getSection(int book)
What section is this book a part of? |
static String |
getSectionName(int section)
Get the full name of a book (e.g. |
static String |
getShortBookName(int book)
Get the short name of a book (e.g. |
private static String |
getString(ResourceBundle resources,
String key)
|
private static void |
initialize()
Load up the resources for Bible book and section names, and cache the upper and lower versions of them. |
static boolean |
isBookName(String find)
Is the given string a valid book name. |
static boolean |
isFullBookName()
This is only used by config |
static boolean |
isGospel(int book)
Is this book part of the Gospels? |
static boolean |
isGospelOrActs(int book)
Is this book part of the Gospels or Acts? |
static boolean |
isHistory(int book)
Is this book part of the OT History? |
static boolean |
isLetter(int book)
Is this book part of the letters? |
static boolean |
isMajorProphet(int book)
Is this book part of the major prophets? |
static boolean |
isMinorProphet(int book)
Is this book part of the minor prophets? |
static boolean |
isPentateuch(int book)
Is this book part of the Pentateuch? |
static boolean |
isPoetry(int book)
Is this book part of the OT History? |
static int[] |
patch(int[] ref)
Fix up these verses so that they are as valid a possible. |
static void |
setCase(CaseType newBookCase)
How do we report the names of the books?. |
static void |
setCase(int bookCase)
This is only used by config. |
static void |
setFullBookName(boolean fullName)
Set whether the name should be full or abbreviated, long or short. |
static void |
validate(int[] ref)
Does the following represent a real verse? |
static void |
validate(int book,
int chapter,
int verse)
Does the following represent a real verse?. |
static int |
verseCount(int[] ref1,
int[] ref2)
How many verses between ref1 and ref2 (inclusive). |
static int |
verseCount(int book1,
int chapter1,
int verse1,
int book2,
int chapter2,
int verse2)
How many verses between ref1 and ref2 (inclusive). |
static int |
verseOrdinal(int[] ref)
Where does this verse come in the Bible. |
static int |
verseOrdinal(int book,
int chapter,
int verse)
Where does this verse come in the Bible. |
static int |
versesInBible()
Count the verses in the Bible. |
static int |
versesInBook(int book)
Count the verses in a book. |
static int |
versesInChapter(int book,
int chapter)
Count the verses in a chapter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final String FULL_KEY
private static final String SHORT_KEY
private static final String ALT_KEY
private static final String SECTION_KEY
private static final String OSIS_KEY
private static final String OSIS_PROPERTIES
private static CaseType bookCase
private static boolean fullBookName
public static final int BOOK
public static final int CHAPTER
public static final int VERSE
private static String[] fullBooks
private static String[] fullBooksLower
private static String[] fullBooksUpper
private static String[] shortBooks
private static String[] shortBooksLower
private static Map shortBooksMap
private static String[] shortBooksUpper
private static String[][] altBooksLower
private static Map altBooksMap
private static String[] osisBooks
private static Map osisMap
private static String[] sections
private static String[] sectionsLower
private static String[] sectionsUpper
private static final int SECTIONS_IN_BIBLE
private static final int BOOKS_IN_BIBLE
private static final int CHAPTERS_IN_BIBLE
static final short[] CHAPTERS_IN_BOOK
static final short VERSES_IN_BIBLE
static final short[] VERSES_IN_BOOK
static final short[][] VERSES_IN_CHAPTER
static final short[] ORDINAL_AT_START_OF_BOOK
static final short[][] ORDINAL_AT_START_OF_CHAPTER
static final short[] BOOKS_IN_SECTION
protected static final BibleInfo instance
| Constructor Detail |
|---|
private BibleInfo()
| Method Detail |
|---|
private static void initialize()
private static String getString(ResourceBundle resources,
String key)
public static void setCase(int bookCase)
bookCase - The new case to use for reporting book names
IllegalArgumentException - If the case is not between 0 and 2Passage,
getCase()public static int getCase()
Passage,
setCase(CaseType)public static void setCase(CaseType newBookCase)
newBookCase - The new case to use for reporting book names
IllegalArgumentException - If the case is not between 0 and 2Passage,
getCase()public static boolean isFullBookName()
setFullBookName(boolean)public static void setFullBookName(boolean fullName)
fullName - The new case to use for reporting book namesisFullBookName()public static CaseType getDefaultCase()
Passage,
setCase(int)
public static String getBookName(int book)
throws NoSuchVerseException
book - The book number (1-66)
NoSuchVerseException - If the book number is not valid
public static String getLongBookName(int book)
throws NoSuchVerseException
book - The book number (1-66)
NoSuchVerseException - If the book number is not valid
public static String getShortBookName(int book)
throws NoSuchVerseException
book - The book number (1-66)
NoSuchVerseException - If the book number is not valid
public static String getOSISName(int book)
throws NoSuchVerseException
book - The book number (1-66)
NoSuchVerseException - If the book number is not validpublic static int getBookNumber(String find)
find - The string to identify
public static boolean isBookName(String find)
find - The string to identify
public static int booksInBible()
public static int chaptersInBible()
public static int versesInBible()
public static int chaptersInBook(int book)
throws NoSuchVerseException
book - The book part of the reference.
NoSuchVerseException - If the book number is not valid
public static int versesInChapter(int book,
int chapter)
throws NoSuchVerseException
book - The book part of the reference.chapter - The current chapter
NoSuchVerseException - If the book or chapter number is not valid
public static int versesInBook(int book)
throws NoSuchVerseException
book - The book part of the reference.
NoSuchVerseException - If the book number is not valid
public static int verseOrdinal(int book,
int chapter,
int verse)
throws NoSuchVerseException
book - The book part of the reference.chapter - The current chapterverse - The current verse
NoSuchVerseException - If the reference is illegal
public static int verseOrdinal(int[] ref)
throws NoSuchVerseException
ref - An array of 3 ints, book, chapter, verse
NoSuchVerseException - If the reference is illegal
public static int[] decodeOrdinal(int ordinal)
throws NoSuchVerseException
ordinal - The ordinal number of the verse
NoSuchVerseException - If the reference is illegal
public static void validate(int 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 illegal
public static void validate(int[] ref)
throws NoSuchVerseException
ref - An array of 3 ints, book, chapter, verse
NoSuchVerseException - If the reference is illegalpublic static int[] patch(int[] ref)
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 comentary 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 dispite this maybe we should provide the functionality anyway.
ref - An array of 3 ints, book, chapter, verse. This array will be changed.
public static int verseCount(int book1,
int chapter1,
int verse1,
int book2,
int chapter2,
int verse2)
throws NoSuchVerseException
book1 - The book part of the first reference.chapter1 - The chapter part of the first reference.verse1 - The verse part of the first reference.book2 - The book part of the second reference.chapter2 - The chapter part of the second reference.verse2 - The verse part of the second reference.
NoSuchVerseException - If either reference is illegal
public static int verseCount(int[] ref1,
int[] ref2)
throws NoSuchVerseException
ref1 - An array of 3 ints, book, chapter, verse for the first reference.ref2 - An array of 3 ints, book, chapter, verse for the second reference.
NoSuchVerseException - If either reference is illegalpublic static boolean isPentateuch(int book)
book - The book to test
public static boolean isHistory(int book)
book - The book to test
public static boolean isPoetry(int book)
book - The book to test
public static boolean isMajorProphet(int book)
book - The book to test
public static boolean isMinorProphet(int book)
book - The book to test
public static boolean isGospel(int book)
book - The book to test
public static boolean isGospelOrActs(int book)
book - The book to test
public static boolean isLetter(int book)
book - The book to test
public static int getSection(int book)
book - The book to test
BibleInfo.Sectionpublic static int booksInSection(int section)
section - The section
getSection(int)
public static String getSectionName(int section)
throws NoSuchVerseException
section - The book number (1-66)
NoSuchVerseException - If the book number is not validprotected static boolean containsLetter(String text)
text - The string to be parsed
|
Copyright ? 2003-2006 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||