org.crosswire.jsword.book
Class Books

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

public final class Books
extends Object
implements BookList

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

Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors.

Field Summary
private  BookSet books
          The list of Books
private  Set drivers
          An array of BookDrivers
private static Books instance
          The singleton instance.
private  EventListenerList listeners
          The list of listeners
protected static Logger log
          The log stream
private  boolean threaded
          Do we try to get clever in registering books?.
 
Constructor Summary
private Books()
          Create a singleton instance of the class.
 
Method Summary
 void addBook(Book book)
          Add a Bible to the current list of Books.
 void addBooksListener(BooksListener li)
          Remove a BibleListener from our list of listeners
protected  void autoRegister()
          Registers all the drivers known to the program.
protected  void fireBooksChanged(Object source, Book book, boolean added)
          Kick of an event sequence
 Book getBook(String name)
           
 List getBooks()
          Get a list of all the Books of all types.
 List getBooks(BookFilter filter)
          Get a filtered list of all the Books.
 BookDriver[] getDrivers()
          Get an array of all the known drivers
 BookDriver[] getDriversByClass(Class type)
          Since Books keeps a track of drivers itself, including creating them when registered it can be hard to get ahold of the current book driver.
 BookDriver[] getWritableDrivers()
          Get an array of all the known drivers
private  void initialize(boolean doThreading)
          Registers all the drivers known to the program.
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 Bible from the current list of Books.
 void removeBooksListener(BooksListener li)
          Add a BibleListener to our list of listeners
 void unregisterDriver(BookDriver driver)
          Remove from the list of drivers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

books

private BookSet books
The list of Books


drivers

private Set drivers
An array of BookDrivers


listeners

private EventListenerList listeners
The list of listeners


threaded

private boolean threaded
Do we try to get clever in registering books?. Not until we can get it to work! At this time there is no way to set this or influence it So it just acts as a means of commenting out code.


log

protected static final 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 getBooks()
Description copied from interface: BookList
Get a list of all the Books of all types.

Specified by:
getBooks in interface BookList

getBook

public Book getBook(String name)

getBooks

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

Specified by:
getBooks in interface BookList
See Also:
BookFilters

addBooksListener

public void addBooksListener(BooksListener li)
Description copied from interface: BookList
Remove a BibleListener from our list of listeners

Specified by:
addBooksListener in interface BookList
Parameters:
li - The old listener

removeBooksListener

public void removeBooksListener(BooksListener li)
Description copied from interface: BookList
Add a BibleListener to our list of listeners

Specified by:
removeBooksListener in interface BookList
Parameters:
li - The new listener

fireBooksChanged

protected void fireBooksChanged(Object source,
                                Book book,
                                boolean added)
Kick of an event sequence

Parameters:
source - The event source
book - The changed Book
added - Is it added?

addBook

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


removeBook

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

Throws:
BookException

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

unregisterDriver

public void unregisterDriver(BookDriver driver)
                      throws BookException
Remove from the list of drivers

Parameters:
driver - The BookDriver to remove
Throws:
BookException

getDriversByClass

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


getDrivers

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

Returns:
Found int or the default value

getWritableDrivers

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

Returns:
Found int or the default value

initialize

private void initialize(boolean doThreading)
Registers all the drivers known to the program. Either in a thread or in the main thread


autoRegister

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


Copyright ยจ 2003-2006