org.crosswire.bibledesktop.book

## Class BooksListModel

- java.lang.Object
- - javax.swing.AbstractListModel
  - - org.crosswire.bibledesktop.book.BooksListModel

- All Implemented Interfaces:
    Serializable, ListModel
  Direct Known Subclasses:
    BooksComboBoxModel

      public class BooksListModel
      extends AbstractListModel

  BooksListModel creates a Swing ListModel from the available Bibles. I would normally implement BooksListener in an inner class however doing that would stop me calling fireInterval*() in AbstractListModel because that is a protected method and the inner class is neither in the same package or a sub class.
  Author:
    Joe Walker
  See Also:
    `for license details.`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) class` | `BooksListModel.CustomListDataListener` So we can get a handle on what Bibles there are

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private org.crosswire.jsword.book.BookList` | `bookList` The list of books in this tree
    `protected List<org.crosswire.jsword.book.Book>` | `books` The array of versions.
    `protected Comparator<org.crosswire.jsword.book.Book>` | `comparator` The sort algorithm to use.
    `private org.crosswire.jsword.book.BookFilter` | `filter` The filter used to choose Bibles
    `private BooksListModel.CustomListDataListener` | `listener` The listener
    `private static org.slf4j.Logger` | `log` The log stream
    `private static long` | `serialVersionUID` Serialization ID

    - ### Fields inherited from class javax.swing.AbstractListModel

      `listenerList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BooksListModel()` Basic constructor
    `BooksListModel(org.crosswire.jsword.book.BookFilter filter)` Basic constructor
    `BooksListModel(org.crosswire.jsword.book.BookFilter filter, org.crosswire.jsword.book.BookList bookList, Comparator<org.crosswire.jsword.book.Book> comparator)` Basic constructor for a filtered list of books, ordered as requested.
    `BooksListModel(org.crosswire.jsword.book.BookFilter filter, Comparator<org.crosswire.jsword.book.Book> comp)` Basic constructor, redefining ordering.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListDataListener(ListDataListener li)`
    `protected void` | `cacheData()` Setup the data-stores of the current Bibles and drivers
    `protected void` | `fireContentsChanged(Object source, int index0, int index1)`
    `Object` | `getElementAt(int index)`
    `int` | `getIndexOf(Object test)` Returns the index-position of the specified object in the list.
    `int` | `getSize()`
    `private void` | `readObject(ObjectInputStream is)` Serialization support.
    `void` | `removeListDataListener(ListDataListener li)`
    `void` | `setFilter(org.crosswire.jsword.book.BookFilter filter)`

    - ### Methods inherited from class javax.swing.AbstractListModel

      `fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners`

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

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

- - ### Field Detail

    - #### bookList

          private transient org.crosswire.jsword.book.BookList bookList

      The list of books in this tree

    - #### filter

          private transient org.crosswire.jsword.book.BookFilter filter

      The filter used to choose Bibles

    - #### listener

          private transient BooksListModel.CustomListDataListener listener

      The listener

    - #### books

          protected transient List<org.crosswire.jsword.book.Book> books

      The array of versions. All methods that access this variable have been marked synchronized to ensure that one thread can't update the list of books while another is trying to create a JList based on this class.

    - #### comparator

          protected transient Comparator<org.crosswire.jsword.book.Book> comparator

      The sort algorithm to use.

    - #### log

          private static final org.slf4j.Logger log

      The log stream

    - #### serialVersionUID

          private static final long serialVersionUID

      Serialization ID
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BooksListModel

          public BooksListModel()

      Basic constructor

    - #### BooksListModel

          public BooksListModel(org.crosswire.jsword.book.BookFilter filter)

      Basic constructor

    - #### BooksListModel

          public BooksListModel(org.crosswire.jsword.book.BookFilter filter,
                        Comparator<org.crosswire.jsword.book.Book> comp)

      Basic constructor, redefining ordering.

    - #### BooksListModel

          public BooksListModel(org.crosswire.jsword.book.BookFilter filter,
                        org.crosswire.jsword.book.BookList bookList,
                        Comparator<org.crosswire.jsword.book.Book> comparator)

      Basic constructor for a filtered list of books, ordered as requested.

  - ### Method Detail

    - #### getSize

          public int getSize()

    - #### getElementAt

          public Object getElementAt(int index)

    - #### getIndexOf

          public int getIndexOf(Object test)

      Returns the index-position of the specified object in the list.
      Parameters:
        `test` - the object to find
      Returns:
        an int representing the index position, where 0 is the first position

    - #### setFilter

          public void setFilter(org.crosswire.jsword.book.BookFilter filter)

      Parameters:
        `filter` -

    - #### addListDataListener

          public void addListDataListener(ListDataListener li)

      Specified by:
        `addListDataListener` in interface `ListModel`
      Overrides:
        `addListDataListener` in class `AbstractListModel`

    - #### removeListDataListener

          public void removeListDataListener(ListDataListener li)

      Specified by:
        `removeListDataListener` in interface `ListModel`
      Overrides:
        `removeListDataListener` in class `AbstractListModel`

    - #### cacheData

          protected final void cacheData()

      Setup the data-stores of the current Bibles and drivers

    - #### fireContentsChanged

          protected void fireContentsChanged(Object source,
                                 int index0,
                                 int index1)

      Overrides:
        `fireContentsChanged` in class `AbstractListModel`

    - #### readObject

          private void readObject(ObjectInputStream is)
                           throws IOException,
                                  ClassNotFoundException

      Serialization support.
      Parameters:
        `is` -
      Throws:
        `IOException`
        `ClassNotFoundException`