org.crosswire.jsword.book.basic
Class AbstractPassageBook

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

public abstract class AbstractPassageBook
extends AbstractBook

An abstract implementation of Book that lets implementors just concentrate on reading book data.

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

Field Summary
private  KeyFactory keyf
          Our key manager
private static Logger log
          The log stream
 
Constructor Summary
AbstractPassageBook()
           
 
Method Summary
 void addOSIS(Key key, org.jdom.Element div, List osisContent)
          Add the OSIS elements to the div element.
 Key createEmptyKeyList()
          Fetch an empty Key to which we can add Keys.
 BookData getData(Key key)
          Retrieval: Add to the given document some mark-up for the specified Verses.
protected abstract  Filter getFilter()
          What filter should be used to filter data in the format produced by this Book?.
 Key getGlobalKeyList()
          Get a complete list of index entries.
 Key getKey(String text)
          Someone has typed in a reference to find, but we need a Key to actually look it up.
 String getRawData(Key key)
          Returns the raw text that getData(Key key) builds into OSIS.
protected abstract  String getText(Key key)
          Read the unfiltered data for a given key
 Key getValidKey(String name)
          Get a Key for the name, if possible.
 void setDocument(Verse verse, BookData bdata)
          For when we want to add writing functionality
protected abstract  void setText(Verse verse, String text)
          Set the unparsed text for a verse to permanent storage.
 
Methods inherited from class org.crosswire.jsword.book.basic.AbstractBook
activate, addIndexStatusListener, compareTo, deactivate, equals, find, find, firePropertyChange, getBook, getBookCategory, getBookMetaData, getDriver, getDriverName, getFullName, getIndexStatus, getInitials, getLanguage, getName, getOsisID, getProperties, getUnlockKey, hasFeature, hashCode, isEnciphered, isLeftToRight, isLocked, isQuestionable, isSupported, removeIndexStatusListener, setBookMetaData, setIndexStatus, toOSIS, toString, unlock
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

keyf

private KeyFactory keyf
Our key manager


log

private static final Logger log
The log stream

Constructor Detail

AbstractPassageBook

public AbstractPassageBook()
Method Detail

getData

public BookData getData(Key key)
                 throws BookException
Description copied from interface: Book
Retrieval: Add to the given document some mark-up for the specified Verses.

Parameters:
key - The verses to search for
Returns:
The found Book data
Throws:
BookException - If anything goes wrong with this method

addOSIS

public void addOSIS(Key key,
                    org.jdom.Element div,
                    List osisContent)
Add the OSIS elements to the div element. Note, this assumes that the data is fully marked up.

Parameters:
key - The key being added
div - The div element to which the key is being added
osisContent - The OSIS representation of the key being added.

getFilter

protected abstract Filter getFilter()
What filter should be used to filter data in the format produced by this Book?. In some ways this method is more suited to BookMetaData however we do not have a specialization of BookMetaData to fit AbstractPassageBook and it doesn't like any higher in the hierachy at the moment so I will leave this here.


getText

protected abstract String getText(Key key)
                           throws BookException
Read the unfiltered data for a given key

Throws:
BookException

setDocument

public void setDocument(Verse verse,
                        BookData bdata)
                 throws BookException
For when we want to add writing functionality

Throws:
BookException

setText

protected abstract void setText(Verse verse,
                                String text)
                         throws BookException
Set the unparsed text for a verse to permanent storage.

Throws:
BookException

createEmptyKeyList

public final Key createEmptyKeyList()
Description copied from interface: KeyFactory
Fetch an empty Key to which we can add Keys. Not all implementations of Key are able to hold any type of Key, It isn't reasonable to expect a Key of Bible verses (=Passage) to hold a dictionary Key. So each KeyFactory must be able to create you an empty Key to which you can safely add other Keys it generates.

Returns:
An empty Key that can hold other Keys from this factory.

getGlobalKeyList

public final Key getGlobalKeyList()
Description copied from interface: KeyFactory
Get a complete list of index entries. Create a Key that encompasses all of the known valid keys for the given context. For a dictionary this will include all of the entries in the dictionary, for a Bible this will probably include all the verses in the Bible, but a commentary may well miss some out.

Returns:
A Key that includes all of the known Keys

getValidKey

public Key getValidKey(String name)
Description copied from interface: KeyFactory
Get a Key for the name, if possible. Otherwise return an empty Key.

Returns:
a valid key.

getKey

public final Key getKey(String text)
                 throws NoSuchKeyException
Description copied from interface: KeyFactory
Someone has typed in a reference to find, but we need a Key to actually look it up. So we create a Key from the string if such a translation is possible. The returned Key may be a BranchKey if the string represents more than one Key.

Parameters:
text - The string to translate into a Key
Returns:
The Key corresponding to the input text
Throws:
NoSuchKeyException - If the name can not be parsed.

getRawData

public String getRawData(Key key)
                  throws BookException
Description copied from interface: Book
Returns the raw text that getData(Key key) builds into OSIS.

Parameters:
key - The verses to search for
Returns:
The found Book data
Throws:
BookException - If anything goes wrong with this method

Copyright ยจ 2003-2006