org.crosswire.jsword.book.sword
Class AbstractBackend

java.lang.Object
  extended by org.crosswire.jsword.book.sword.AbstractBackend
All Implemented Interfaces:
Activatable
Direct Known Subclasses:
AbstractKeyBackend, GenBookBackend, RawBackend, ZVerseBackend

public abstract class AbstractBackend
extends Object
implements Activatable

A generic way to read data from disk for later formatting.

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  SwordBookMetaData bmd
           
 
Constructor Summary
AbstractBackend()
          Default constructor for the sake of serialization.
AbstractBackend(SwordBookMetaData sbmd)
          Construct a minimal backend
 
Method Summary
abstract  boolean contains(Key key)
           
 void decipher(byte[] data)
          Decipher the data in place, if it is enciphered and there is a key to unlock it.
 void encipher(byte[] data)
          Encipher the data in place, if there is a key to unlock it.
 SwordBookMetaData getBookMetaData()
           
 URI getExpandedDataPath()
           
abstract  String getRawText(Key key)
          Get the text allotted for the given entry
 boolean isSupported()
          Returns whether this AbstractBackend is implemented.
 boolean isWritable()
          A Backend is writable if the file system allows the underlying files to be opened for writing and if the backend has implemented writing.
 Key readIndex()
          Initialize a AbstractBackend before use.
 void setRawText(Key key, String text)
          Set the text allotted for the given verse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.crosswire.common.activate.Activatable
activate, deactivate
 

Field Detail

bmd

private SwordBookMetaData bmd
Constructor Detail

AbstractBackend

public AbstractBackend()
Default constructor for the sake of serialization.


AbstractBackend

public AbstractBackend(SwordBookMetaData sbmd)
Construct a minimal backend

Parameters:
sbmd -
Method Detail

getBookMetaData

public SwordBookMetaData getBookMetaData()
Returns:
Returns the Sword BookMetaData.

decipher

public void decipher(byte[] data)
Decipher the data in place, if it is enciphered and there is a key to unlock it.

Parameters:
data - the data to unlock

encipher

public void encipher(byte[] data)
Encipher the data in place, if there is a key to unlock it.

Parameters:
data -

getExpandedDataPath

public URI getExpandedDataPath()
                        throws BookException
Throws:
BookException

readIndex

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


contains

public abstract boolean contains(Key key)

getRawText

public abstract String getRawText(Key key)
                           throws BookException
Get the text allotted for the given entry

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

setRawText

public void setRawText(Key key,
                       String text)
Set the text allotted for the given verse

Parameters:
key - The key to fetch
Throws:
BookException - If the data can not be set.

isSupported

public boolean isSupported()
Returns whether this AbstractBackend is implemented.

Returns:
true if this AbstractBackend is implemented.

isWritable

public boolean isWritable()
A Backend is writable if the file system allows the underlying files to be opened for writing and if the backend has implemented writing. Ultimately, all drivers should allow writing. At this time writing is not supported by backends, so abstract implementations should return false and let specific implementations return true otherwise.

Returns:
true if the book is writable

Copyright ยจ 2003-2007