T
- The type of the RawBackendState that this class extends.public class RawBackend<T extends RawBackendState> extends AbstractBackend<RawBackendState>
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
protected int |
datasize
How many bytes in the size count in the index
|
protected int |
entrysize
The number of bytes for each entry in the index: either 6 or 8
|
private static org.slf4j.Logger |
log
The log stream
|
protected static int |
OFFSETSIZE
How many bytes in the offset pointers in the index
|
Constructor and Description |
---|
RawBackend(SwordBookMetaData sbmd,
int datasize)
Simple ctor
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Key key)
Determine whether this Book contains the key in question
|
protected String |
getEntry(RawBackendState state,
String name,
Testament testament,
long index)
Get the text for an indexed entry in the book.
|
Key |
getGlobalKeyList()
Gets the fast global key list, and if this operation is not supported, throws a
UnsupportedOperationException |
protected DataIndex |
getIndex(RandomAccessFile raf,
long entry)
Get the Index (that is offset and size) for an entry.
|
String |
getRawText(RawBackendState state,
Key key) |
int |
getRawTextLength(Key key)
Determine the size of the raw data for the key in question.
|
T |
initState()
Initialises the state required to read from files, specific to each
different backend
|
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.
|
String |
readRawContent(RawBackendState state,
Key key) |
void |
setAliasKey(RawBackendState state,
Key alias,
Key source)
Sets alias for a comment on a verse range I.e.
|
void |
setRawText(RawBackendState state,
Key key,
String text)
Set the text allotted for the given verse
|
create, decipher, encipher, getBookMetaData, getRawText, isSupported, readIndex, readToOsis, setAliasKey
protected final int datasize
protected final int entrysize
protected static final int OFFSETSIZE
private static final org.slf4j.Logger log
public RawBackend(SwordBookMetaData sbmd, int datasize)
sbmd
- datasize
- public boolean contains(Key key)
Backend
contains
in interface Backend<RawBackendState>
contains
in class AbstractBackend<RawBackendState>
key
- The key whose presence is desired.public int getRawTextLength(Key key)
Backend
getRawTextLength
in interface Backend<RawBackendState>
getRawTextLength
in class AbstractBackend<RawBackendState>
key
- The key whose raw data length is desired.public Key getGlobalKeyList() throws BookException
Backend
UnsupportedOperationException
getGlobalKeyList
in interface Backend<RawBackendState>
getGlobalKeyList
in class AbstractBackend<RawBackendState>
BookException
- the book exception if for some reason the book failed to be read properly.public T initState() throws BookException
StatefulFileBackedBackend
BookException
public String getRawText(RawBackendState state, Key key) throws IOException
IOException
public String readRawContent(RawBackendState state, Key key) throws IOException
state
- the state object containing all the open random access fileskey
- the verse that is soughtIOException
- something went wrong when reading the versepublic void setRawText(RawBackendState state, Key key, String text) throws BookException, IOException
StatefulFileBackedBackend
state
- TODOkey
- The key to set text totext
- The text to be set for keyBookException
- If the data can not be set.IOException
- If the module data path could not be created.public boolean isWritable()
Backend
isWritable
in interface Backend<RawBackendState>
isWritable
in class AbstractBackend<RawBackendState>
public void setAliasKey(RawBackendState state, Key alias, Key source) throws IOException
StatefulFileBackedBackend
state
- the open file statealias
- Alias Keysource
- Source KeyIOException
- Exception when anything goes wrong on writing the aliasprotected DataIndex getIndex(RandomAccessFile raf, long entry) throws IOException
entry
- IOException
protected String getEntry(RawBackendState state, String name, Testament testament, long index) throws IOException
state
- index
- the entry to getname
- name of the entrytestament
- the testament for the entryIOException
- on a IO problem