public class RawFileBackend extends RawBackend<RawFileBackendState>
The GNU Lesser General Public License for details.| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
log |
datasize, entrysize, OFFSETSIZE| Constructor and Description |
|---|
RawFileBackend(SwordBookMetaData sbmd,
int datasize) |
| Modifier and Type | Method and Description |
|---|---|
private void |
checkAndIncrementIncfile(RawFileBackendState state,
int index) |
void |
create()
Create the directory to hold the Book if it does not exist.
|
private void |
createDataFiles() |
private File |
createDataTextFile(int index) |
private void |
createIncfile(RawFileBackendState state) |
private void |
createIndexFiles() |
private File |
getDataTextFile(RandomAccessFile txtRaf,
DataIndex dataIndex)
Gets the File having the verse text.
|
protected String |
getEntry(RawBackendState state,
String name,
Testament testament,
long index)
Get the text for an indexed entry in the book.
|
private String |
getTextFilename(RandomAccessFile txtRaf,
DataIndex dataIndex)
Gets the Filename for the File having the verse text.
|
RawFileBackendState |
initState()
Initialises the state required to read from files, specific to each
different backend
|
private byte[] |
littleEndian16BitByteArrayFromShort(short val) |
private byte[] |
littleEndian32BitByteArrayFromInt(int val) |
private void |
prepopulateIncfile(RawFileBackendState state) |
private void |
prepopulateIndexFiles(RawFileBackendState state) |
private byte[] |
readTextDataFile(File dataFile) |
void |
setAliasKey(RawFileBackendState state,
Key alias,
Key source) |
void |
setRawText(RawFileBackendState state,
Key key,
String text) |
protected void |
updateDataFile(long ordinal,
File txtFile) |
protected void |
updateIndexFile(RandomAccessFile idxRaf,
long index,
long dataFileStartPosition) |
private void |
writeIncfile(RawFileBackendState state,
int value) |
private void |
writeInitialIndex(BufferedOutputStream outStream) |
private void |
writeTextDataFile(File dataFile,
byte[] textData) |
contains, getGlobalKeyList, getIndex, getRawText, getRawTextLength, isWritable, readRawContent, setAliasKey, setRawTextdecipher, encipher, getBookMetaData, getRawText, isSupported, readIndex, readToOsis, setAliasKeypublic RawFileBackend(SwordBookMetaData sbmd, int datasize)
public RawFileBackendState initState() throws BookException
StatefulFileBackedBackendinitState in interface StatefulFileBackedBackend<RawBackendState>initState in class RawBackend<RawFileBackendState>BookExceptionprotected String getEntry(RawBackendState state, String name, Testament testament, long index) throws IOException
RawBackendgetEntry in class RawBackend<RawFileBackendState>name - name of the entrytestament - the testament for the entryindex - the entry to getIOException - on a IO problempublic void setRawText(RawFileBackendState state, Key key, String text) throws BookException, IOException
BookExceptionIOExceptionpublic void setAliasKey(RawFileBackendState state, Key alias, Key source) throws IOException
IOExceptionprivate File createDataTextFile(int index) throws BookException, IOException
BookExceptionIOExceptionprivate String getTextFilename(RandomAccessFile txtRaf, DataIndex dataIndex) throws IOException
txtRaf - The random access file containing the file names for the verse
storage.dataIndex - The index of where to get the dataIOExceptionprivate File getDataTextFile(RandomAccessFile txtRaf, DataIndex dataIndex) throws IOException, BookException
txtRaf - The random access file containing the file names for the verse
storage.dataIndex - The index of where to get the dataIOExceptionBookExceptionprotected void updateIndexFile(RandomAccessFile idxRaf, long index, long dataFileStartPosition) throws IOException
IOExceptionprotected void updateDataFile(long ordinal,
File txtFile)
throws IOException
IOExceptionprivate void checkAndIncrementIncfile(RawFileBackendState state, int index) throws IOException
IOExceptionpublic void create()
throws IOException,
BookException
Backendcreate in interface Backend<RawBackendState>create in class AbstractBackend<RawBackendState>IOExceptionBookExceptionprivate void createDataFiles()
throws IOException,
BookException
IOExceptionBookExceptionprivate void createIndexFiles()
throws IOException,
BookException
IOExceptionBookExceptionprivate void prepopulateIndexFiles(RawFileBackendState state) throws IOException
IOExceptionprivate void createIncfile(RawFileBackendState state) throws IOException, BookException
IOExceptionBookExceptionprivate void prepopulateIncfile(RawFileBackendState state) throws IOException
IOExceptionprivate void writeIncfile(RawFileBackendState state, int value) throws IOException
IOExceptionprivate void writeInitialIndex(BufferedOutputStream outStream) throws IOException
IOExceptionprivate byte[] readTextDataFile(File dataFile) throws IOException
IOExceptionprivate void writeTextDataFile(File dataFile, byte[] textData) throws IOException
IOExceptionprivate byte[] littleEndian32BitByteArrayFromInt(int val)
private byte[] littleEndian16BitByteArrayFromShort(short val)