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, setRawText
decipher, encipher, getBookMetaData, getRawText, isSupported, readIndex, readToOsis, setAliasKey
public RawFileBackend(SwordBookMetaData sbmd, int datasize)
public RawFileBackendState initState() throws BookException
StatefulFileBackedBackend
initState
in interface StatefulFileBackedBackend<RawBackendState>
initState
in class RawBackend<RawFileBackendState>
BookException
protected String getEntry(RawBackendState state, String name, Testament testament, long index) throws IOException
RawBackend
getEntry
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
BookException
IOException
public void setAliasKey(RawFileBackendState state, Key alias, Key source) throws IOException
IOException
private File createDataTextFile(int index) throws BookException, IOException
BookException
IOException
private 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 dataIOException
private 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 dataIOException
BookException
protected void updateIndexFile(RandomAccessFile idxRaf, long index, long dataFileStartPosition) throws IOException
IOException
protected void updateDataFile(long ordinal, File txtFile) throws IOException
IOException
private void checkAndIncrementIncfile(RawFileBackendState state, int index) throws IOException
IOException
public void create() throws IOException, BookException
Backend
create
in interface Backend<RawBackendState>
create
in class AbstractBackend<RawBackendState>
IOException
BookException
private void createDataFiles() throws IOException, BookException
IOException
BookException
private void createIndexFiles() throws IOException, BookException
IOException
BookException
private void prepopulateIndexFiles(RawFileBackendState state) throws IOException
IOException
private void createIncfile(RawFileBackendState state) throws IOException, BookException
IOException
BookException
private void prepopulateIncfile(RawFileBackendState state) throws IOException
IOException
private void writeIncfile(RawFileBackendState state, int value) throws IOException
IOException
private void writeInitialIndex(BufferedOutputStream outStream) throws IOException
IOException
private byte[] readTextDataFile(File dataFile) throws IOException
IOException
private void writeTextDataFile(File dataFile, byte[] textData) throws IOException
IOException
private byte[] littleEndian32BitByteArrayFromInt(int val)
private byte[] littleEndian16BitByteArrayFromShort(short val)