Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.jsword.book.sword
Class RawFileBackend

    java.lang.Object
      org.crosswire.jsword.book.sword.AbstractBackend<RawBackendState>
          org.crosswire.jsword.book.sword.RawBackend<RawFileBackendState>
              org.crosswire.jsword.book.sword.RawFileBackend

All Implemented Interfaces:
  Backend<RawBackendState>, StatefulFileBackedBackend<RawBackendState>

    public class RawFileBackend

extends RawBackend<RawFileBackendState>

A Raw File format that allows for each verse to have it's own storage. The basic structure of the index is as follows:

- incfile -- Is initialized with 1 and is incremented once for each non-linked verse that is actually stored in the Book.
- idx -- There is one index file for each testament having verses, named nt and ot. These index files contain offsets into the corresponding data file. The idx files are indexed by the ordinal value of the verse within the Testament for the Book's versification.
- dat -- There is a data file for each testament having verses, named nt.vss and ot.vss. These data files do not contain the verses but rather the file names that contain the verse text.
- verse -- For each stored verse there is a file containing the verse text. The filename is a zero padded number corresponding to the current increment from incfile, when it was created. It is this 7 character name that is stored in a dat file.

Author:
  mbergmann, DM Smith
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private static org.slf4j.Logger` | `log`

Fields inherited from class org.crosswire.jsword.book.sword.RawBackend
`datasize, entrysize, OFFSETSIZE`

Constructor Summary
`RawFileBackend(SwordBookMetaData sbmd, int datasize)`

Method Summary
`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)`

Methods inherited from class org.crosswire.jsword.book.sword.RawBackend
`contains, getGlobalKeyList, getIndex, getRawText, getRawTextLength, isWritable, readRawContent, setAliasKey, setRawText`

Methods inherited from class org.crosswire.jsword.book.sword.AbstractBackend
`decipher, encipher, getBookMetaData, getRawText, isSupported, readIndex, readToOsis, setAliasKey`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.slf4j.Logger log

Constructor Detail

### RawFileBackend

    public RawFileBackend(SwordBookMetaData sbmd,
                          int datasize)

Method Detail

### initState

    public RawFileBackendState initState()
                                  throws BookException

  Description copied from interface: `StatefulFileBackedBackend`
  Initialises the state required to read from files, specific to each different backend

  Specified by:
    `initState` in interface `StatefulFileBackedBackend<RawBackendState>`
  Overrides:
    `initState` in class `RawBackend<RawFileBackendState>`
  Returns:
    the state that has been initialised
  Throws:
    `BookException`

### getEntry

    protected String getEntry(RawBackendState state,
                              String name,
                              Testament testament,
                              long index)
                       throws IOException

  Description copied from class: `RawBackend`
  Get the text for an indexed entry in the book.

  Overrides:
    `getEntry` in class `RawBackend<RawFileBackendState>`
    `name` - name of the entry
    `testament` - the testament for the entry
    `index` - the entry to get
  Returns:
    the text for the entry.
  Throws:
    `IOException` - on a IO problem

### setRawText

    public void setRawText(RawFileBackendState state,
                           Key key,
                           String text)
                    throws BookException,
                           IOException

  Throws:
    `BookException`
    `IOException`

### setAliasKey

    public void setAliasKey(RawFileBackendState state,
                            Key alias,
                            Key source)
                     throws IOException

  Throws:
    `IOException`

### createDataTextFile

    private File createDataTextFile(int index)
                             throws BookException,
                                    IOException

  Throws:
    `BookException`
    `IOException`

### getTextFilename

    private String getTextFilename(RandomAccessFile txtRaf,
                                   DataIndex dataIndex)
                            throws IOException

  Gets the Filename for the File having the verse text.

  Parameters:
    `txtRaf` - The random access file containing the file names for the verse storage.
    `dataIndex` - The index of where to get the data
  Returns:
    the file having the verse text.
  Throws:
    `IOException`

### getDataTextFile

    private File getDataTextFile(RandomAccessFile txtRaf,
                                 DataIndex dataIndex)
                          throws IOException,
                                 BookException

  Gets the File having the verse text.

  Parameters:
    `txtRaf` - The random access file containing the file names for the verse storage.
    `dataIndex` - The index of where to get the data
  Returns:
    the file having the verse text.
  Throws:
    `IOException`
    `BookException`

### updateIndexFile

    protected void updateIndexFile(RandomAccessFile idxRaf,
                                   long index,
                                   long dataFileStartPosition)
                            throws IOException

  Throws:
    `IOException`

### updateDataFile

    protected void updateDataFile(long ordinal,
                                  File txtFile)
                           throws IOException

  Throws:
    `IOException`

### checkAndIncrementIncfile

    private void checkAndIncrementIncfile(RawFileBackendState state,
                                          int index)
                                   throws IOException

  Throws:
    `IOException`

### create

    public void create()
                throws IOException,
                       BookException

  Description copied from interface: `Backend`
  Create the directory to hold the Book if it does not exist.

  Specified by:
    `create` in interface `Backend<RawBackendState>`
  Overrides:
    `create` in class `AbstractBackend<RawBackendState>`
  Throws:
    `IOException`
    `BookException`

### createDataFiles

    private void createDataFiles()
                          throws IOException,
                                 BookException

  Throws:
    `IOException`
    `BookException`

### createIndexFiles

    private void createIndexFiles()
                           throws IOException,
                                  BookException

  Throws:
    `IOException`
    `BookException`

### prepopulateIndexFiles

    private void prepopulateIndexFiles(RawFileBackendState state)
                                throws IOException

  Throws:
    `IOException`

### createIncfile

    private void createIncfile(RawFileBackendState state)
                        throws IOException,
                               BookException

  Throws:
    `IOException`
    `BookException`

### prepopulateIncfile

    private void prepopulateIncfile(RawFileBackendState state)
                             throws IOException

  Throws:
    `IOException`

### writeIncfile

    private void writeIncfile(RawFileBackendState state,
                              int value)
                       throws IOException

  Throws:
    `IOException`

### writeInitialIndex

    private void writeInitialIndex(BufferedOutputStream outStream)
                            throws IOException

  Throws:
    `IOException`

### readTextDataFile

    private byte[] readTextDataFile(File dataFile)
                             throws IOException

  Throws:
    `IOException`

### writeTextDataFile

    private void writeTextDataFile(File dataFile,
                                   byte[] textData)
                            throws IOException

  Throws:
    `IOException`

### littleEndian32BitByteArrayFromInt

    private byte[] littleEndian32BitByteArrayFromInt(int val)

### littleEndian16BitByteArrayFromShort

    private byte[] littleEndian16BitByteArrayFromShort(short val)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2015
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD