org.crosswire.jsword.versification

## Class BibleBookList

- java.lang.Object
- - org.crosswire.jsword.versification.BibleBookList

- All Implemented Interfaces:
    Serializable, Iterable<BibleBook>

       class BibleBookList
      extends Object
      implements Iterable<BibleBook>, Serializable

  A BibleBookList is an ordered list of one or more BibleBooks. Typically, a BibleBookList is a member of a Versification.
  Author:
    DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int[]` | `bookMap` The bookMap maps from a BibleBook to the position that it has in `books`.
    `protected BibleBook[]` | `books` The ordered books in this list
    `private static long` | `serialVersionUID` Serialization ID

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BibleBookList(BibleBook[] books)` Create an ordered BibleBookList from the input.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(BibleBook book)` Does this Versification contain the BibleBook.
    `BibleBook` | `getBook(int ordinal)` Get the BibleBook by its position in this Versification.
    `int` | `getBookCount()` Get the number of books in this Versification.
    `BibleBook` | `getFirstBook()` Return the first book in the list.
    `BibleBook` | `getLastBook()` Return the first book in the list.
    `BibleBook` | `getNextBook(BibleBook book)` Given a BibleBook, get the next BibleBook in this Versification.
    `int` | `getOrdinal(BibleBook book)` Where does the BibleBook come in the order of books of the Bible.
    `BibleBook` | `getPreviousBook(BibleBook book)` Given a BibleBook, get the previous BibleBook in this Versification.
    `private void` | `initialize()` The bookMap contains one slot for every BibleBook, indexed by it's ordinal value.
    `Iterator<BibleBook>` | `iterator()` Get the BibleBooks in this Versification.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### books

          protected BibleBook[] books

      The ordered books in this list

    - #### bookMap

          private int[] bookMap

      The bookMap maps from a BibleBook to the position that it has in `books`.

    - #### serialVersionUID

          private static final long serialVersionUID

      Serialization ID
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BibleBookList

          BibleBookList(BibleBook[] books)

      Create an ordered BibleBookList from the input.
      Parameters:
        `books` -

  - ### Method Detail

    - #### contains

          public boolean contains(BibleBook book)

      Does this Versification contain the BibleBook.
      Parameters:
        `book` -
      Returns:
        true if it is present.

    - #### getOrdinal

          public int getOrdinal(BibleBook book)

      Where does the BibleBook come in the order of books of the Bible. The first book is 0, the next is 1 and so forth. If the BibleBook is not in this Reference System, then the return value of this routine is -1.
      Parameters:
        `book` -
      Returns:
        the ordinal value of the book or -1 if not present

    - #### getBookCount

          public int getBookCount()

      Get the number of books in this Versification.
      Returns:
        the number of books

    - #### getBook

          public BibleBook getBook(int ordinal)

      Get the BibleBook by its position in this Versification. If the position is negative, return the first book. If the position is greater than the last, return the last book.
      Parameters:
        `ordinal` -
      Returns:
        the indicated book

    - #### iterator

          public Iterator<BibleBook> iterator()

      Get the BibleBooks in this Versification.
      Specified by:
        `iterator` in interface `Iterable<BibleBook>`
      Returns:
        an Iterator over the books

    - #### getFirstBook

          public BibleBook getFirstBook()

      Return the first book in the list.
      Returns:
        the first book in the list

    - #### getLastBook

          public BibleBook getLastBook()

      Return the first book in the list.
      Returns:
        the first book in the list

    - #### getPreviousBook

          public BibleBook getPreviousBook(BibleBook book)

      Given a BibleBook, get the previous BibleBook in this Versification. If it is the first book, return null.
      Parameters:
        `book` - A BibleBook in the Versification
      Returns:
        the previous BibleBook or null.

    - #### getNextBook

          public BibleBook getNextBook(BibleBook book)

      Given a BibleBook, get the next BibleBook in this Versification. If it is the last book, return null.
      Parameters:
        `book` - A BibleBook in the Versification
      Returns:
        the previous BibleBook or null.

    - #### initialize

          private void initialize()

      The bookMap contains one slot for every BibleBook, indexed by it's ordinal value. The value of that entry is the position of the book in the BookList. If the BibleBook is not present in books, it's value is -1.