Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.jsword.passage
Class BibleInfo

    java.lang.Object
      org.crosswire.jsword.passage.BibleInfo

    public class BibleInfo

extends Object

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.

Distribution Licence: JSword 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, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA The copyright to this program is held by it's authors.

Version:
  $Id: BibleInfo.java,v 1.30 2005/03/23 12:53:31 dmsmith Exp $
Author:
  Joe Walker [joe at eireneh dot com]
See Also:
  `Licence`

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
`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
`private static short[]` | `CHAPTERS_IN_BOOK` Constant for the number of chapters in each book
`private static String` | `FULL_KEY`
`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.
`private static short[]` | `ORDINAL_AT_START_OF_BOOK` Constant for the ordinal number of the first verse in each book
`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
`private static short` | `VERSES_IN_BIBLE` Constant for the number of verses in the Bible
`private static short[]` | `VERSES_IN_BOOK` Constant for the number of verses in each book
`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 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` | `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` | `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

### FULL_KEY

    private static final String FULL_KEY

See Also:
  Constant Field Values

### SHORT_KEY

    private static final String SHORT_KEY

See Also:
  Constant Field Values

### ALT_KEY

    private static final String ALT_KEY

See Also:
  Constant Field Values

### SECTION_KEY

    private static final String SECTION_KEY

See Also:
  Constant Field Values

### OSIS_KEY

    private static final String OSIS_KEY

See Also:
  Constant Field Values

### OSIS_PROPERTIES

    private static final String OSIS_PROPERTIES

See Also:
  Constant Field Values

### bookCase

    private static CaseType bookCase

  How the book names are reported

### 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

### fullBooks

    private static String[] fullBooks

  The full names of the book of the Bible, in mixed case

### fullBooksLower

    private static String[] fullBooksLower

  The full names of the book of the Bible, in lower case, generated at run time

### fullBooksUpper

    private static String[] fullBooksUpper

  The full names of the book of the Bible, in upper case, generated at run time

### shortBooks

    private static String[] shortBooks

  Standard shortened names for the book of the Bible, in mixed case

### shortBooksLower

    private static String[] shortBooksLower

  Standard shortened names for the book of the Bible, in lower case, generated at run time

### shortBooksMap

    private static Map shortBooksMap

  Standard shortened names for the book of the Bible, in lower case, generated at runtime.

### shortBooksUpper

    private static String[] shortBooksUpper

  Standard shortened names for the book of the Bible, in upper case, generated at run time

### altBooksLower

    private static String[][] altBooksLower

  Alternative shortened names for the book of the Bible, in lower case

### altBooksMap

    private static Map altBooksMap

  Alternative shortened names for the book of the Bible, in lower case, generated at run time

### osisBooks

    private static String[] osisBooks

  Standard OSIS names for the book of the Bible, in mixed case

### osisMap

    private static Map osisMap

  Standard OSIS names for the book of the Bible, in mixed case

### sections

    private static String[] sections

  Standard names for the sections

### sectionsLower

    private static String[] sectionsLower

  Standard Bible section names, in lower case, generated at run time

### sectionsUpper

    private static String[] sectionsUpper

  Standard Bible section names, in upper case, generated at run time

### SECTIONS_IN_BIBLE

    private static final int SECTIONS_IN_BIBLE

  Constant for the number of sections in the Bible

  See Also:
    Constant Field Values

### 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 short[] CHAPTERS_IN_BOOK

  Constant for the number of chapters in each book

### VERSES_IN_BIBLE

    private static final short VERSES_IN_BIBLE

  Constant for the number of verses in the Bible

  See Also:
    Constant Field Values

### VERSES_IN_BOOK

    private static final short[] VERSES_IN_BOOK

  Constant for the number of verses in each book

### VERSES_IN_CHAPTER

    private static final short[][] VERSES_IN_CHAPTER

  Constant for the number of verses in each chapter

### ORDINAL_AT_START_OF_BOOK

    private static final short[] 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 short[][] 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 short[] BOOKS_IN_SECTION

  The number of books in each section

### instance

    protected static final BibleInfo instance

  A singleton used to do initialization. Could be used to change static methods to non-static

Constructor Detail

### BibleInfo

    private BibleInfo()

  Ensure that we can not be instantiated

Method Detail

### initialize

    private static void initialize()

  Load up the resources for Bible book and section names, and cache the upper and lower versions of them.

### getString

    private static String getString(ResourceBundle resources,
                                    String key)

### setCase

    public static final void setCase(int bookCase)

  This is only used by config.

  Parameters:
    `bookCase` - The new case to use for reporting book names
  Throws:
    `IllegalArgumentException` - If the case is not between 0 and 2
  See Also:
    `Passage`, `getCase()`

### getCase

    public static final int getCase()

  This is only used by config

  Returns:
    The current case setting
  See Also:
    `Passage`, `setCase(CaseType)`

### setCase

    public static final void setCase(CaseType newBookCase)

  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. BibleInfo.MIXED is not allowed

  Parameters:
    `newBookCase` - The new case to use for reporting book names
  Throws:
    `IllegalArgumentException` - If the case is not between 0 and 2
  See Also:
    `Passage`, `getCase()`

### getDefaultCase

    public static final CaseType getDefaultCase()

  How do we report the names of the books?.

  Returns:
    The current case setting
  See Also:
    `Passage`, `setCase(int)`

### getLongBookName

    public static final String getLongBookName(int book)
                                        throws NoSuchVerseException

  Get the full name of a book (e.g. "Genesis"). Altered by the case setting (see setBookCase())

  Parameters:
    `book` - The book number (1-66)
  Returns:
    The full name of the book
  Throws:
    `NoSuchVerseException` - If the book number is not valid

### getShortBookName

    public static final String getShortBookName(int book)
                                         throws NoSuchVerseException

  Get the short name of a book (e.g. "Gen"). Altered by the case setting (see setBookCase())

  Parameters:
    `book` - The book number (1-66)
  Returns:
    The short name of the book
  Throws:
    `NoSuchVerseException` - If the book number is not valid

### getOSISName

    public static final String getOSISName(int book)
                                    throws NoSuchVerseException

  Get the OSIS name for a book.

  Parameters:
    `book` - The book number (1-66)
  Returns:
    the OSIS defined short name for a book
  Throws:
    `NoSuchVerseException` - If the book number is not valid

### getBookNumber

    public static final int getBookNumber(String find)

  Get number of a book from its name.

  Parameters:
    `find` - The string to identify
  Returns:
    The book number (1 to 66) On error -1

### isBookName

    public static final boolean isBookName(String find)

  Is the given string a valid book name. If this method returns true then getBookNumber() will return a number and not throw an exception.

  Parameters:
    `find` - The string to identify
  Returns:
    The book number (1 to 66)

### booksInBible

    public static final int booksInBible()

  Count the books in the Bible.

  Returns:
    66 always - the number of books in the Bible

### chaptersInBible

    public static final int chaptersInBible()

  Count the chapters in the Bible.

  Returns:
    1189 always - the number of 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'

  Returns:
    31102 always - the number of verses in the Bible

### chaptersInBook

    public static final int chaptersInBook(int book)
                                    throws NoSuchVerseException

  Count the chapters in this book.

  Parameters:
    `book` - The book part of the reference.
  Returns:
    The number of chapters
  Throws:
    `NoSuchVerseException` - If the book number is not valid

### versesInChapter

    public static final int versesInChapter(int book,
                                            int chapter)
                                     throws NoSuchVerseException

  Count the verses in a chapter.

  Parameters:
    `book` - The book part of the reference.
    `chapter` - The current chapter
  Returns:
    The number of verses
  Throws:
    `NoSuchVerseException` - If the book or chapter number is not valid

### versesInBook

    public static final int versesInBook(int book)
                                  throws NoSuchVerseException

  Count the verses in a book.

  Parameters:
    `book` - The book part of the reference.
  Returns:
    The number of verses
  Throws:
    `NoSuchVerseException` - If the book number is not valid

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

  Parameters:
    `book` - The book part of the reference.
    `chapter` - The current chapter
    `verse` - The current verse
  Returns:
    The ordinal number of verses
  Throws:
    `NoSuchVerseException` - If the reference is illegal

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

  Parameters:
    `ref` - An array of 3 ints, book, chapter, verse
  Returns:
    The ordinal number of the verse
  Throws:
    `NoSuchVerseException` - If the reference is illegal

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

  Parameters:
    `ordinal` - The ordinal number of the verse
  Returns:
    An array of 3 ints, book, chapter, verse
  Throws:
    `NoSuchVerseException` - If the reference is illegal

### 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 :(

  Parameters:
    `book` - The book part of the reference.
    `chapter` - The chapter part of the reference.
    `verse` - The verse part of the reference.
  Throws:
    `NoSuchVerseException` - If the reference is illegal

### validate

    public static final void validate(int[] ref)
                               throws NoSuchVerseException

  Does the following represent a real verse?

  Parameters:
    `ref` - An array of 3 ints, book, chapter, verse
  Throws:
    `NoSuchVerseException` - If the reference is illegal

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

  Parameters:
    `ref` - An array of 3 ints, book, chapter, verse. This array will be changed.
  Returns:
    The original array that has been patched.

### 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).

  Parameters:
    `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.
  Returns:
    the number of verses
  Throws:
    `NoSuchVerseException` - If either reference is illegal

### verseCount

    public static final int verseCount(int[] ref1,
                                       int[] ref2)
                                throws NoSuchVerseException

  How many verses between ref1 and ref2 (inclusive).

  Parameters:
    `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.
  Returns:
    the number of verses
  Throws:
    `NoSuchVerseException` - If either reference is illegal

### isPentateuch

    public static final boolean isPentateuch(int book)

  Is this book part of the Pentateuch?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isHistory

    public static final boolean isHistory(int book)

  Is this book part of the OT History?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isPoetry

    public static final boolean isPoetry(int book)

  Is this book part of the OT History?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isMajorProphet

    public static final boolean isMajorProphet(int book)

  Is this book part of the major prophets?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isMinorProphet

    public static final boolean isMinorProphet(int book)

  Is this book part of the minor prophets?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isGospel

    public static final boolean isGospel(int book)

  Is this book part of the Gospels?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isGospelOrActs

    public static final boolean isGospelOrActs(int book)

  Is this book part of the Gospels or Acts?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### isLetter

    public static final boolean isLetter(int book)

  Is this book part of the letters?

  Parameters:
    `book` - The book to test
  Returns:
    True if this book is a part of this section

### getSection

    public static final int getSection(int book)

  What section is this book a part of?

  Parameters:
    `book` - The book to test
  Returns:
    True The section
  See Also:
    `BibleInfo.Section`

### booksInSection

    public static final int booksInSection(int section)

  How many books are there in each of the above sections

  Parameters:
    `section` - The section
  Returns:
    The number of books in the given section
  See Also:
    `getSection(int)`

### getSectionName

    public static final String getSectionName(int section)
                                       throws NoSuchVerseException

  Get the full name of a book (e.g. "Genesis"). Altered by the case setting (see setBookCase())

  Parameters:
    `section` - The book number (1-66)
  Returns:
    The full name of the book
  Throws:
    `NoSuchVerseException` - If the book number is not valid

### containsLetter

    protected static boolean containsLetter(String text)

  This is simply a convenience function to wrap Character.isLetter()

  Parameters:
    `text` - The string to be parsed
  Returns:
    true if the string contains letters

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ? 2003-2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD