T - The type of the OpenFileState that this class extends.public abstract class AbstractBackend<T extends OpenFileState> extends Object implements StatefulFileBackedBackend<T>, Backend<T>
The GNU Lesser General Public License for details.| Modifier and Type | Field and Description |
|---|---|
private SwordBookMetaData |
bmd |
private static org.slf4j.Logger |
LOGGER |
| Constructor and Description |
|---|
AbstractBackend()
Default constructor for the sake of serialization.
|
AbstractBackend(SwordBookMetaData sbmd)
Construct a minimal backend
|
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
contains(Key key)
Determine whether this Book contains the key in question
|
void |
create()
Create the directory to hold the Book if it does not exist.
|
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.
|
BookMetaData |
getBookMetaData() |
Key |
getGlobalKeyList()
Gets the fast global key list, and if this operation is not supported, throws a
UnsupportedOperationException |
String |
getRawText(Key key)
Get the text as it is found in the Book for the given key
|
int |
getRawTextLength(Key key)
Determine the size of the raw data for the key in question.
|
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.
|
private void |
readNormalOsis(Key key,
RawTextToXmlProcessor processor,
List<org.jdom2.Content> content,
T openFileState) |
private void |
readNormalOsisSingleKey(Key key,
RawTextToXmlProcessor processor,
List<org.jdom2.Content> content,
T openFileState)
Avoid using iterator for GenBook TreeKeys which would cause a GenBook nodes children to be appended to their parent
e.g.
|
private Verse |
readPassageOsis(Key key,
RawTextToXmlProcessor processor,
List<org.jdom2.Content> content,
T openFileState)
Reads a passage as OSIS
|
List<org.jdom2.Content> |
readToOsis(Key key,
RawTextToXmlProcessor processor)
Get the text allotted for the given entry
|
void |
setAliasKey(Key alias,
Key source) |
private void |
throwFailedKeyException(Key masterKey,
Key currentKey,
IOException e)
If non-null, currentKey is used to throw the exception, other, masterKey
is used instead, which will be more general.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitState, readRawContent, setAliasKey, setRawTextprivate SwordBookMetaData bmd
private static final org.slf4j.Logger LOGGER
public AbstractBackend()
public AbstractBackend(SwordBookMetaData sbmd)
sbmd - public BookMetaData getBookMetaData()
getBookMetaData in interface Backend<T extends OpenFileState>public void decipher(byte[] data)
Backenddecipher in interface Backend<T extends OpenFileState>data - the data to unlockpublic void encipher(byte[] data)
Backendencipher in interface Backend<T extends OpenFileState>public Key readIndex()
BackendreadIndex in interface Backend<T extends OpenFileState>public abstract boolean contains(Key key)
Backendcontains in interface Backend<T extends OpenFileState>key - The key whose presence is desired.public String getRawText(Key key) throws BookException
BackendgetRawText in interface Backend<T extends OpenFileState>key - the key for which the raw text is desired.BookExceptionpublic void setAliasKey(Key alias, Key source) throws BookException
setAliasKey in interface Backend<T extends OpenFileState>BookExceptionpublic int getRawTextLength(Key key)
BackendgetRawTextLength in interface Backend<T extends OpenFileState>key - The key whose raw data length is desired.public Key getGlobalKeyList() throws BookException
BackendUnsupportedOperationExceptiongetGlobalKeyList in interface Backend<T extends OpenFileState>BookException - the book exception if for some reason the book failed to be read properly.public List<org.jdom2.Content> readToOsis(Key key, RawTextToXmlProcessor processor) throws BookException
BackendreadToOsis in interface Backend<T extends OpenFileState>key - The key to fetchprocessor - processor that executes before/after the content is read from
disk or another kind of backendBookException - If the data can not be read.private void readNormalOsis(Key key, RawTextToXmlProcessor processor, List<org.jdom2.Content> content, T openFileState) throws BookException
BookExceptionprivate void readNormalOsisSingleKey(Key key, RawTextToXmlProcessor processor, List<org.jdom2.Content> content, T openFileState) throws BookException
BookExceptionprivate Verse readPassageOsis(Key key, RawTextToXmlProcessor processor, List<org.jdom2.Content> content, T openFileState) throws BookException
key - the given keyprocessor - a processor for which to do things withcontent - a list of content to be appended to (i.e. the OSIS data)openFileState - the open file state, from which we read thingsBookException - a book exception if we failed to read the bookprivate void throwFailedKeyException(Key masterKey, Key currentKey, IOException e) throws BookException
masterKey - the key containing currentKeycurrentKey - the currentKeye - the exception that occuredBookException - always thrown, a BookExceptionpublic void create()
throws IOException,
BookException
Backendcreate in interface Backend<T extends OpenFileState>IOExceptionBookExceptionpublic boolean isSupported()
BackendisSupported in interface Backend<T extends OpenFileState>public boolean isWritable()
BackendisWritable in interface Backend<T extends OpenFileState>