Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.eireneh.bible.passage
Class Books  view Books download Books.java

java.lang.Object
  extended bycom.eireneh.bible.passage.Books
All Implemented Interfaces:
PassageConstants

public class Books
extends java.lang.Object
implements PassageConstants

Books 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 Books 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.
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

Nested Class Summary
static class Books.Names
          Handy book finder
static class Books.Section
          Handy section finder.
 
Field Summary
private static java.lang.String[][] alt_books
          Alternative shortened names for the book of the Bible, in mixed case
private static java.lang.String[][] alt_books_lower
          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 int book_case
          How the book names are reported
private static int books_in_bible
          Constant for the number of books in the Bible
private static int[] 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
private static int[] chapters_in_book
          Constant for the number of chapters in each book
private static java.lang.String[] full_books
          The full names of the book of the Bible, in mixed case
private static java.lang.String[] full_books_lower
          The full names of the book of the Bible, in lower case, generated at run time
private static java.lang.String[] full_books_upper
          The full names of the book of the Bible, in upper case, generated at run time
private static java.lang.String[] jog_books
          The memory jogger names for the books of the Bible
private static java.lang.String[] jog_numbers
          The memory jogger names for the numbers
protected static com.eireneh.util.Logger log
          The log stream
private static int[] ordinal_at_start_of_book
          Constant for the ordinal number of the first verse in each book
private static int[][] ordinal_at_start_of_chapter
          Constant for the ordinal number of the first verse in each chapter.
private static java.util.ResourceBundle resources
          The resource file, for book names
private static java.lang.String[] sections
          Standard names for the sections
private static java.lang.String[] sections_lower
          Standard Bible section names, in lower case, generated at run time
private static java.lang.String[] sections_upper
          Standard Bible section names, in upper case, generated at run time
private static java.lang.String[] short_books
          Standard shortened names for the book of the Bible, in mixed case
private static java.lang.String[] short_books_lower
          Standard shortened names for the book of the Bible, in lower case, generated at run time
private static java.lang.String[] short_books_upper
          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
private static int verses_in_bible
          Constant for the number of verses in the Bible
private static int[] verses_in_book
          Constant for the number of verses in each book
private static int[][] verses_in_chapter
          Constant for the number of verses in each chapter
 
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
private Books()
          Ensure that we can not be instansiated
 
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.
static int[] decodeOrdinal(int ordinal)
          Where does this verse come in the Bible.
static java.lang.String getBookJogger(int book)
          Get the memory jogger letters for a book.
static int getBookNumber(java.lang.String find)
          Get number of a book from its name.
static int getCase()
          How do we report the names of the books?.
static java.lang.String getLongBookName(int book)
          Get the full name of a book (e.g.
static java.lang.String getNumberJogger(long number)
          Get the Short name of a book
static int getSection(int book)
          What section is this book a part of?
static java.lang.String getSectionName(int section)
          Get the full name of a book (e.g.
static java.lang.String getShortBookName(int book)
          Get the short name of a book (e.g.
static boolean isBookName(java.lang.String find)
          Is the given string a valid book name.
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(int book_case)
          How do we report the names of the books?.
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? It is code like this that makes me wonder if I18 is done well/worth doing.
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

book_case

private static int book_case
How the book names are reported


resources

private static java.util.ResourceBundle resources
The resource file, for book names


BOOK

public static final int BOOK
Used for methods with int[3] parameters, for the book

See Also:
Constant Field Values

CHAPTER

public static final int CHAPTER
Used for methods with int[3] parameters, for the chapter

See Also:
Constant Field Values

VERSE

public static final int VERSE
Used for methods with int[3] parameters, for the verse

See Also:
Constant Field Values

full_books

private static java.lang.String[] full_books
The full names of the book of the Bible, in mixed case


short_books

private static java.lang.String[] short_books
Standard shortened names for the book of the Bible, in mixed case


sections

private static java.lang.String[] sections
Standard names for the sections


alt_books

private static java.lang.String[][] alt_books
Alternative shortened names for the book of the Bible, in mixed case


full_books_lower

private static java.lang.String[] full_books_lower
The full names of the book of the Bible, in lower case, generated at run time


short_books_lower

private static java.lang.String[] short_books_lower
Standard shortened names for the book of the Bible, in lower case, generated at run time


alt_books_lower

private static java.lang.String[][] alt_books_lower
Alternative shortened names for the book of the Bible, in lower case, generated at run time


full_books_upper

private static java.lang.String[] full_books_upper
The full names of the book of the Bible, in upper case, generated at run time


short_books_upper

private static java.lang.String[] short_books_upper
Standard shortened names for the book of the Bible, in upper case, generated at run time


sections_upper

private static java.lang.String[] sections_upper
Standard Bible section names, in upper case, generated at run time


sections_lower

private static java.lang.String[] sections_lower
Standard Bible section names, in lower case, generated at run time


jog_books

private static final java.lang.String[] jog_books
The memory jogger names for the books of the Bible


jog_numbers

private static final java.lang.String[] jog_numbers
The memory jogger names for the numbers


books_in_bible

private static final int books_in_bible
Constant for the number of books in the Bible

See Also:
Constant Field Values

chapters_in_bible

private static final int chapters_in_bible
Constant for the number of chapters in the Bible

See Also:
Constant Field Values

chapters_in_book

private static final int[] chapters_in_book
Constant for the number of chapters in each book


verses_in_bible

private static final int verses_in_bible
Constant for the number of verses in the Bible

See Also:
Constant Field Values

verses_in_book

private static final int[] verses_in_book
Constant for the number of verses in each book


verses_in_chapter

private static final int[][] verses_in_chapter
Constant for the number of verses in each chapter


ordinal_at_start_of_book

private static final int[] ordinal_at_start_of_book
Constant for the ordinal number of the first verse in each book


ordinal_at_start_of_chapter

private static final int[][] ordinal_at_start_of_chapter
Constant for the ordinal number of the first verse in each chapter. Warning if you regenerate this code (from the code at the bottom of this module) then you will need to cut the psalms line in half to get it to compile under JBuilder.


books_in_section

private static final int[] books_in_section
The number of books in each section


log

protected static com.eireneh.util.Logger log
The log stream

Constructor Detail

Books

private Books()
Ensure that we can not be instansiated

Method Detail

setCase

public static final void setCase(int book_case)
How do we report the names of the books?. These are static. This is on the assumption that we will not want to have different sections of the app using a different format. I expect this to be a good assumption, and it saves passing a Book class around everywhere. Books.MIXED is not allowed


getCase

public static final int getCase()
How do we report the names of the books?.


getLongBookName

public static final java.lang.String getLongBookName(int book)
                                              throws NoSuchVerseException
Get the full name of a book (e.g. "Genesis"). Altered by the case setting (see setBookCase())


getShortBookName

public static final java.lang.String getShortBookName(int book)
                                               throws NoSuchVerseException
Get the short name of a book (e.g. "Gen"). Altered by the case setting (see setBookCase())


getBookJogger

public static final java.lang.String getBookJogger(int book)
                                            throws NoSuchVerseException
Get the memory jogger letters for a book.


getNumberJogger

public static final java.lang.String getNumberJogger(long number)
Get the Short name of a book


getBookNumber

public static final int getBookNumber(java.lang.String find)
                               throws NoSuchVerseException
Get number of a book from its name.


isBookName

public static final boolean isBookName(java.lang.String find)
                                throws NoSuchVerseException
Is the given string a valid book name. If this method returns true then getBookNumber() will return a number and not throw an exception.


booksInBible

public static final int booksInBible()
Count the books in the Bible.


chaptersInBible

public static final int chaptersInBible()
Count the chapters in the Bible.


versesInBible

public static final int versesInBible()
Count the verses in the Bible. This counts possible verses, so this number is not affected by some versions missing out some verses as 'there in error'


chaptersInBook

public static final int chaptersInBook(int book)
                                throws NoSuchVerseException
Count the chapters in this book.


versesInChapter

public static final int versesInChapter(int book,
                                        int chapter)
                                 throws NoSuchVerseException
Count the verses in a chapter.


versesInBook

public static final int versesInBook(int book)
                              throws NoSuchVerseException
Count the verses in a book.


verseOrdinal

public static final int verseOrdinal(int book,
                                     int chapter,
                                     int verse)
                              throws NoSuchVerseException
Where does this verse come in the Bible. Starting with Gen 1:1 as number 1 counting up one per verse and not resetting at each new chapter.


verseOrdinal

public static final int verseOrdinal(int[] ref)
                              throws NoSuchVerseException
Where does this verse come in the Bible. Starting with Gen 1:1 as number 1 counting up one per verse and not resetting at each new chapter.


decodeOrdinal

public static final int[] decodeOrdinal(int ordinal)
                                 throws NoSuchVerseException
Where does this verse come in the Bible. Starting with Gen 1:1 as number 1 counting up one per verse and not resetting at each new chapter.


validate

public static final void validate(int book,
                                  int chapter,
                                  int verse)
                           throws NoSuchVerseException
Does the following represent a real verse? It is code like this that makes me wonder if I18 is done well/worth doing. All this code does is check if the numbers are valid, but the exception handling code is huge :(


validate

public static final void validate(int[] ref)
                           throws NoSuchVerseException
Does the following represent a real verse?


patch

public static final int[] patch(int[] ref)
Fix up these verses so that they are as valid a possible. This is currently done so that we can say "Gen 1:1" + 31 = "Gen 1:32" and "Gen 1:32".patch() is "Gen 2:1".

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.


verseCount

public static final int verseCount(int book1,
                                   int chapter1,
                                   int verse1,
                                   int book2,
                                   int chapter2,
                                   int verse2)
                            throws NoSuchVerseException
How many verses between ref1 and ref2 (inclusive).


verseCount

public static final int verseCount(int[] ref1,
                                   int[] ref2)
                            throws NoSuchVerseException
How many verses between ref1 and ref2 (inclusive).


isPentateuch

public static final boolean isPentateuch(int book)
Is this book part of the Pentateuch?


isHistory

public static final boolean isHistory(int book)
Is this book part of the OT History?


isPoetry

public static final boolean isPoetry(int book)
Is this book part of the OT History?


isMajorProphet

public static final boolean isMajorProphet(int book)
Is this book part of the major prophets?


isMinorProphet

public static final boolean isMinorProphet(int book)
Is this book part of the minor prophets?


isGospel

public static final boolean isGospel(int book)
Is this book part of the Gospels?


isGospelOrActs

public static final boolean isGospelOrActs(int book)
Is this book part of the Gospels or Acts?


isLetter

public static final boolean isLetter(int book)
Is this book part of the letters?


getSection

public static final int getSection(int book)
What section is this book a part of?


booksInSection

public static final int booksInSection(int section)
How many books are there in each of the above sections


getSectionName

public static final java.lang.String getSectionName(int section)
                                             throws NoSuchVerseException
Get the full name of a book (e.g. "Genesis"). Altered by the case setting (see setBookCase())