org.crosswire.jsword.book.sword
Class GenBookBackend

java.lang.Object
  extended by org.crosswire.jsword.book.sword.AbstractBackend
      extended by org.crosswire.jsword.book.sword.GenBookBackend
All Implemented Interfaces:
Activatable

public class GenBookBackend
extends AbstractBackend

Backend for General Books.

Author:
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  boolean active
          Are we active
private  File bdtFile
          The raw data file
private  RandomAccessFile bdtRaf
          The random access file for the raw data
private static String EXTENSION_BDT
          Raw GenBook file extensions
private  TreeKeyIndex index
          The raw index file
private static Logger log
          The log stream
 
Constructor Summary
GenBookBackend(SwordBookMetaData sbmd)
          Simple ctor
 
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.
protected  void checkActive()
          Helper method so we can quickly activate ourselves on access
 boolean contains(Key key)
           
 void deactivate(Lock lock)
          Called to indicate that the Book should release whatever system resources it can to make way for other uses.
private  void doReadIndex(TreeNode parentNode, Key parentKey)
          A helper function to recursively read the entire tree.
private  TreeNode find(Key key)
          Given a Key, find the TreeNode for it.
 String getRawText(Key key)
          Get the text allotted for the given entry
 Key readIndex()
          Initialize a AbstractBackend before use.
 
Methods inherited from class org.crosswire.jsword.book.sword.AbstractBackend
decipher, encipher, getBookMetaData, getExpandedDataPath, isSupported, isWritable, setRawText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION_BDT

private static final String EXTENSION_BDT
Raw GenBook file extensions

See Also:
Constant Field Values

bdtFile

private File bdtFile
The raw data file


bdtRaf

private RandomAccessFile bdtRaf
The random access file for the raw data


index

private TreeKeyIndex index
The raw index file


active

private boolean active
Are we active


log

private static final Logger log
The log stream

Constructor Detail

GenBookBackend

public GenBookBackend(SwordBookMetaData sbmd)
Simple ctor

Method Detail

activate

public final 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.

Parameters:
lock - An attempt to ensure that only the Activator calls this method

deactivate

public final 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.

Parameters:
lock - An attempt to ensure that only the Activator calls this method

contains

public boolean contains(Key key)
Specified by:
contains in class AbstractBackend

getRawText

public String getRawText(Key key)
                  throws BookException
Description copied from class: AbstractBackend
Get the text allotted for the given entry

Specified by:
getRawText in class AbstractBackend
Parameters:
key - The key to fetch
Returns:
String The data for the verse in question
Throws:
BookException - If the data can not be read.

find

private TreeNode find(Key key)
               throws IOException
Given a Key, find the TreeNode for it.

Parameters:
key - The key to use for searching
Returns:
the found node, null otherwise
Throws:
IOException

readIndex

public Key readIndex()
Description copied from class: AbstractBackend
Initialize a AbstractBackend before use. This method needs to call addKey() a number of times on GenBookBackend

Overrides:
readIndex in class AbstractBackend

doReadIndex

private void doReadIndex(TreeNode parentNode,
                         Key parentKey)
                  throws IOException
A helper function to recursively read the entire tree.

Parameters:
parentNode - the current node whose children are being sought
parentKey -
Throws:
IOException

checkActive

protected final void checkActive()
Helper method so we can quickly activate ourselves on access


Copyright ยจ 2003-2007