org.crosswire.jsword.book
Class Books

java.lang.Object
  extended by org.crosswire.jsword.book.AbstractBookList
      extended by org.crosswire.jsword.book.Books
All Implemented Interfaces:
BookList

public final class Books
extends AbstractBookList

The Books class (along with Book) is the central point of contact between the rest of the world and this set of packages.

Author:
Joe Walker, DM Smith
See Also:
The GNU Lesser General Public License for details.

Field Summary
private  Set<Book> books
          The collection of Books
private  Set<BookDriver> drivers
          An array of BookDrivers
private  Map<String,Book> initials
          The map of book initials
private static Books instance
          The singleton instance.
private static org.slf4j.Logger log
          The log stream
private  Map<String,Book> names
          The map of book names
 
Constructor Summary
private Books()
          Create a singleton instance of the class.
 
Method Summary
 void addBook(Book book)
          Add a Book to the current list of Books.
private  void autoRegister()
          Registers all the drivers known to the program.
 Book getBook(String name)
          Search for the book by initials and name.
 List<Book> getBooks()
          Get a list of all the Books of all types.
 List<Book> getBooks(BookFilter filter)
          Get a filtered list of all the Books.
 BookDriver[] getDrivers()
          Get an array of all the known drivers
 BookDriver[] getDriversByClass(Class<? extends BookDriver> type)
          Since Books keeps a track of drivers itself, including creating them when registered it can be hard to get a hold of the current book driver.
static Books installed()
          Accessor for the singleton instance
 void registerDriver(BookDriver driver)
          Register the driver, adding its books to the list.
 void removeBook(Book book)
          Remove a Book from the current list of Books.
 
Methods inherited from class org.crosswire.jsword.book.AbstractBookList
addBooksListener, fireBooksChanged, removeBooksListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

books

private Set<Book> books
The collection of Books


initials

private Map<String,Book> initials
The map of book initials


names

private Map<String,Book> names
The map of book names


drivers

private Set<BookDriver> drivers
An array of BookDrivers


log

private static final org.slf4j.Logger log
The log stream


instance

private static final Books instance
The singleton instance. This needs to be declared after all other statics it uses.

Constructor Detail

Books

private Books()
Create a singleton instance of the class. This is private to ensure that only one can be created. This also makes the class final!

Method Detail

installed

public static Books installed()
Accessor for the singleton instance

Returns:
The singleton instance

getBooks

public List<Book> getBooks()
Description copied from interface: BookList
Get a list of all the Books of all types.

Returns:
the desired list of books

getBooks

public List<Book> getBooks(BookFilter filter)
Description copied from interface: BookList
Get a filtered list of all the Books.

Specified by:
getBooks in interface BookList
Overrides:
getBooks in class AbstractBookList
Parameters:
filter - the filter to apply to the list of books
Returns:
the desired list of books
See Also:
BookFilters

getBook

public Book getBook(String name)
Search for the book by initials and name. Looks for exact matches first, then searches case insensitive. In all cases the whole initials or the whole name has to match.

Parameters:
name - The initials or name of the book to find
Returns:
the book or null

addBook

public void addBook(Book book)
Add a Book to the current list of Books. This method should only be called by BibleDrivers, it is not a method for general consumption.

Parameters:
book - the book to add to this book list

removeBook

public void removeBook(Book book)
                throws BookException
Remove a Book from the current list of Books. This method should only be called by BibleDrivers, it is not a method for general consumption.

Parameters:
book - the book to be removed from this book list
Throws:
BookException - when an error occurs when performing this method

registerDriver

public void registerDriver(BookDriver driver)
                    throws BookException
Register the driver, adding its books to the list. Any books that this driver used, but not any more are removed. This can be called repeatedly to re-register the driver.

Parameters:
driver - The BookDriver to add
Throws:
BookException - when an error occurs when performing this method

getDriversByClass

public BookDriver[] getDriversByClass(Class<? extends BookDriver> type)
Since Books keeps a track of drivers itself, including creating them when registered it can be hard to get a hold of the current book driver. This method gives access to the registered instances.

Parameters:
type - the type of BookDriver
Returns:
matching BookDrivers

getDrivers

public BookDriver[] getDrivers()
Get an array of all the known drivers

Returns:
Found int or the default value

autoRegister

private void autoRegister()
Registers all the drivers known to the program.


Copyright ยจ 2003-2015