org.crosswire.jsword.book.basic
Class AbstractBook

java.lang.Object
  extended by org.crosswire.jsword.book.basic.AbstractBook
All Implemented Interfaces:
Comparable, Activatable, Book, BookMetaData, KeyFactory
Direct Known Subclasses:
PassageAbstractBook, ReadingsBook, SwordDictionary

public abstract class AbstractBook
extends Object
implements Book

AbstractBook implements a few of the more generic methods of Book. This class does a lot of work in helping make search easier, and implementing some basic write methods.

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: AbstractBook.java,v 1.13 2005/03/21 02:37:28 dmsmith Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Field Summary
private  BookMetaData bmd
          The meta data for this book
private  Searcher searcher
          How do we perform searches
 
Fields inherited from interface org.crosswire.jsword.book.BookMetaData
KEY_BOOK, KEY_DRIVER, KEY_INDEXSTATUS, KEY_INITIALS, KEY_LANGUAGE, KEY_NAME, KEY_TYPE
 
Constructor Summary
AbstractBook()
           
 
Method Summary
 void activate(Lock lock)
          Called to indicate that the Book should initialize itself, and consume whatever system resources it needs to be able to respond to other queries.
 void addPropertyChangeListener(PropertyChangeListener li)
          Adds a PropertyChangeListener to the listener list.
 int compareTo(Object obj)
           
 void deactivate(Lock lock)
          Called to indicate that the Book should release whatever system resources it can to make way for other uses.
 boolean equals(Object obj)
           
 Key find(String search)
          Retrieval: For a given search spec find a list of references to it.
 Book getBook()
           
 BookMetaData getBookMetaData()
          Meta-Information: What version of the Bible is this?
 BookDriver getDriver()
          Accessor for the driver that runs this Book.
 String getDriverName()
          Calculated field: The name of the name, which could be helpful to distinguish similar Books available through 2 BookDrivers.
 String getFullName()
          Calculated field: The full name of the book, for example The format is "name, (Driver)"
 IndexStatus getIndexStatus()
          Has anyone generated a search index for this Book?
 String getInitials()
          The initials of this book - how people familiar with this book will know it, for example "NIV", "KJV".
 String getLanguage()
          The language of the book is the common name for the iso639 code.
 String getName()
          The name of the book, for example "King James Version" or "Bible in Basic English" or "Greek".
 String getOsisID()
          Calculated field: Get an OSIS identifier for the OsisText.setOsisIDWork() and the Work.setOsisWork() methods.
 Map getProperties()
          Get a list of all the properties available to do with this Book.
 BookType getType()
          What type of content is this, a Bible or a reference work like a Dictionary or Commentary
 boolean hasFeature(FeatureType feature)
          Return whether the feature is supported by the book.
 int hashCode()
           
 boolean isLeftToRight()
          Return the orientation of the language of the Book.
 void removePropertyChangeListener(PropertyChangeListener li)
          Removes a PropertyChangeListener from the listener list.
 void setBookMetaData(BookMetaData bmd)
          Set the meta-information for this book.
 void setIndexStatus(IndexStatus status)
          This method does not alter the index status, however it is for Indexers that are responsible for indexing and have changed the status themselves.
 org.jdom.Document toOSIS()
          Get an OSIS representation of information concerning this Book.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.crosswire.jsword.book.Book
getData, getRawData
 
Methods inherited from interface org.crosswire.jsword.passage.KeyFactory
createEmptyKeyList, getGlobalKeyList, getKey
 

Field Detail

searcher

private Searcher searcher
How do we perform searches


bmd

private BookMetaData bmd
The meta data for this book

Constructor Detail

AbstractBook

public AbstractBook()
Method Detail

getBookMetaData

public final BookMetaData getBookMetaData()
Description copied from interface: Book
Meta-Information: What version of the Bible is this?

Specified by:
getBookMetaData in interface Book
Returns:
A Version for this Bible

setBookMetaData

public final void setBookMetaData(BookMetaData bmd)
Description copied from interface: Book
Set the meta-information for this book.

Specified by:
setBookMetaData in interface Book

activate

public void activate(Lock lock)
Description copied from interface: Activatable
Called to indicate that the Book should initialize itself, and consume whatever system resources it needs to be able to respond to other queries.

Specified by:
activate in interface Activatable
Parameters:
lock - An attempt to ensure that only the Activator calls this method

deactivate

public void deactivate(Lock lock)
Description copied from interface: Activatable
Called to indicate that the Book should release whatever system resources it can to make way for other uses.

Specified by:
deactivate in interface Activatable
Parameters:
lock - An attempt to ensure that only the Activator calls this method

find

public Key find(String search)
         throws BookException
Description copied from interface: Book
Retrieval: For a given search spec find a list of references to it. If there are no matches then null should be returned, otherwise a valid Key.

Specified by:
find in interface Book
Parameters:
search - The search spec.
Throws:
BookException - If anything goes wrong with this method

getBook

public Book getBook()

getDriver

public BookDriver getDriver()
Description copied from interface: BookMetaData
Accessor for the driver that runs this Book. Note this method should only be used to delete() Books. Everything else you should want to do to a Book should be available in other ways.

Specified by:
getDriver in interface BookMetaData

getDriverName

public String getDriverName()
Description copied from interface: BookMetaData
Calculated field: The name of the name, which could be helpful to distinguish similar Books available through 2 BookDrivers.

Specified by:
getDriverName in interface BookMetaData
Returns:
The driver name

getFullName

public String getFullName()
Description copied from interface: BookMetaData
Calculated field: The full name of the book, for example The format is "name, (Driver)"

Specified by:
getFullName in interface BookMetaData
Returns:
The full name of this book

getIndexStatus

public IndexStatus getIndexStatus()
Description copied from interface: BookMetaData
Has anyone generated a search index for this Book?

Specified by:
getIndexStatus in interface BookMetaData
See Also:
IndexManager

setIndexStatus

public void setIndexStatus(IndexStatus status)
Description copied from interface: BookMetaData
This method does not alter the index status, however it is for Indexers that are responsible for indexing and have changed the status themselves.

Specified by:
setIndexStatus in interface BookMetaData
See Also:
IndexManager

getInitials

public String getInitials()
Description copied from interface: BookMetaData
The initials of this book - how people familiar with this book will know it, for example "NIV", "KJV".

Specified by:
getInitials in interface BookMetaData
Returns:
The book's initials

getLanguage

public String getLanguage()
Description copied from interface: BookMetaData
The language of the book is the common name for the iso639 code.

Specified by:
getLanguage in interface BookMetaData
Returns:
the common name for the language

getName

public String getName()
Description copied from interface: BookMetaData
The name of the book, for example "King James Version" or "Bible in Basic English" or "Greek". In general it should be possible to deduce the initials from the name by removing all the non-capital letters. Although this is only a generalization. This method should not return null or a blank string.

Specified by:
getName in interface BookMetaData
Returns:
The name of this book

getOsisID

public String getOsisID()
Description copied from interface: BookMetaData
Calculated field: Get an OSIS identifier for the OsisText.setOsisIDWork() and the Work.setOsisWork() methods. The response will generally be of the form [Bible][Dict..].getInitials

Specified by:
getOsisID in interface BookMetaData
Returns:
The osis id of this book

getProperties

public Map getProperties()
Description copied from interface: BookMetaData
Get a list of all the properties available to do with this Book. The returned Properties will be read-only so any attempts to alter it will fail.

Specified by:
getProperties in interface BookMetaData

getType

public BookType getType()
Description copied from interface: BookMetaData
What type of content is this, a Bible or a reference work like a Dictionary or Commentary

Specified by:
getType in interface BookMetaData
Returns:
The type of book

isLeftToRight

public boolean isLeftToRight()
Description copied from interface: BookMetaData
Return the orientation of the language of the Book. If a book contains more than one language, it refers to the dominate language of the book. This will be used to present Arabic and Hebrew in their propper orientation.

Specified by:
isLeftToRight in interface BookMetaData
Returns:
true if the orientation for the dominate language is LeftToRight.

hasFeature

public boolean hasFeature(FeatureType feature)
Description copied from interface: BookMetaData
Return whether the feature is supported by the book.

Specified by:
hasFeature in interface BookMetaData

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener li)
Description copied from interface: BookMetaData
Removes a PropertyChangeListener from the listener list.

Specified by:
removePropertyChangeListener in interface BookMetaData
Parameters:
li - the PropertyChangeListener to be removed

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener li)
Description copied from interface: BookMetaData
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties. However the only one likely to change at the time of writing is the Index Status.

A PropertyChangeEvent will get fired in response to setting a bound property, such as setIndexStatus.

Specified by:
addPropertyChangeListener in interface BookMetaData
Parameters:
li - the PropertyChangeListener to be added

toOSIS

public org.jdom.Document toOSIS()
Description copied from interface: BookMetaData
Get an OSIS representation of information concerning this Book.

Specified by:
toOSIS in interface BookMetaData

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

Copyright ? 2003-2004