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 RawLDBackend

    java.lang.Object
      org.crosswire.jsword.book.sword.AbstractBackend
          org.crosswire.jsword.book.sword.AbstractKeyBackend
              org.crosswire.jsword.book.sword.RawLDBackend

All Implemented Interfaces:
  Serializable, Cloneable, Comparable, Activatable, Iterable, Key

Direct Known Subclasses:
  ZLDBackend

    public class RawLDBackend

extends AbstractKeyBackend

An implementation AbstractKeyBackend to read RAW format files.

Author:
  Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
  `for license details. The copyright to this program is held by it's authors.`, Serialized Form

Field Summary
`private boolean` | `active` Flags whether there are open files or not
`private int` | `datasize` The number of bytes in the size count in the index
`private static MessageFormat` | `DATE_KEY_FORMAT` Date formatter
`private File` | `datFile` The data file
`private RandomAccessFile` | `datRaf` The data random access file
`private int` | `entrysize` The number of bytes for each entry in the index: either 6 or 8
`private File` | `idxFile` The index file
`private RandomAccessFile` | `idxRaf` The index random access file
`private static Logger` | `log` The log stream
`private static int` | `OFFSETSIZE` How many bytes in the offset pointers in the index
`private static long` | `serialVersionUID` Serialization ID
`private int` | `size` The number of entries in the book.
`private static Pattern` | `STRONGS_PATTERN` This is the pattern of a Strong's Number.
`private static DecimalFormat` | `ZERO_4PAD`
`private static DecimalFormat` | `ZERO_5PAD` A means to normalize Strong's Numbers.

Constructor Summary
`RawLDBackend(SwordBookMetaData sbmd, int datasize)` Simple ctor

Method Summary
`void` | `activate(Lock lock)` Called to indicate that the Book should initialize itself, and consume whatever system resources it needs to be able to respond to other queries.
`protected boolean` | `checkActive()` Helper method so we can quickly activate ourselves on access
`void` | `deactivate(Lock lock)` Called to indicate that the Book should release whatever system resources it can to make way for other uses.
`private String` | `external2internal(String externalKey)` Convert the supplied key to something that can be understood by the module.
`Key` | `get(int index)` Gets a key from a specific point in this list of children.
`int` | `getCardinality()` Returns the number of elements in this set (its cardinality).
`private DataEntry` | `getEntry(String reply, int index)` Get the text for an indexed entry in the book.
`private DataIndex` | `getIndex(long entry)` Get the Index (that is offset and size) for an entry.
`protected String` | `getRawText(DataEntry entry)`
`String` | `getRawText(Key key)` Get the text allotted for the given entry
`String` | `getRawText(String key)`
`int` | `indexOf(Key that)` Reverse a Key into the position the key holds in the list of children
`private String` | `internal2external(String internalKey)`
`protected boolean` | `isActive()` Determine whether we are active.
`private String` | `normalizeForSearch(String internalKey)`
`private void` | `readObject(ObjectInputStream is)` Serialization support.
`private int` | `search(String key)` Find a matching entry, returning it's index.

Methods inherited from class org.crosswire.jsword.book.sword.AbstractKeyBackend
`addAll, blur, canHaveChildren, clear, clone, compareTo, contains, equals, getChildCount, getName, getName, getOsisID, getOsisRef, getParent, getRootName, hashCode, isEmpty, iterator, removeAll, retainAll`

Methods inherited from class org.crosswire.jsword.book.sword.AbstractBackend
`decipher, encipher, getBookMetaData, getExpandedDataPath, isSupported, isWritable, readIndex, setRawText`

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

Field Detail

### OFFSETSIZE

    private static final int OFFSETSIZE

  How many bytes in the offset pointers in the index

  See Also:
    Constant Field Values

### active

    private transient boolean active

  Flags whether there are open files or not

### datasize

    private int datasize

  The number of bytes in the size count in the index

### entrysize

    private int entrysize

  The number of bytes for each entry in the index: either 6 or 8

### size

    private transient int size

  The number of entries in the book.

### idxFile

    private transient File idxFile

  The index file

### idxRaf

    private transient RandomAccessFile idxRaf

  The index random access file

### datFile

    private transient File datFile

  The data file

### datRaf

    private transient RandomAccessFile datRaf

  The data random access file

### DATE_KEY_FORMAT

    private static final MessageFormat DATE_KEY_FORMAT

  Date formatter

### STRONGS_PATTERN

    private static final Pattern STRONGS_PATTERN

  This is the pattern of a Strong's Number. It begins with a G or H. Is followed by a number. It can be followed by a ! and a letter or just a letter.

### ZERO_5PAD

    private static final DecimalFormat ZERO_5PAD

  A means to normalize Strong's Numbers.

### ZERO_4PAD

    private static final DecimalFormat ZERO_4PAD

### serialVersionUID

    private static final long serialVersionUID

  Serialization ID

  See Also:
    Constant Field Values

### log

    private static final Logger log

  The log stream

Constructor Detail

### RawLDBackend

    public RawLDBackend(SwordBookMetaData sbmd,
                        int datasize)

  Simple ctor

  Parameters:
    `datasize` - We need to know how many bytes in the size portion of the index

Method Detail

### getRawText

    public String getRawText(Key key)
                      throws BookException

  Description copied from class: `AbstractBackend`
  Get the text allotted for the given entry

  Specified by:
    `getRawText` in class `AbstractBackend`
  Parameters:
    `key` - The key to fetch
  Returns:
    String The data for the verse in question
  Throws:
    `BookException` - If the data can not be read.

### getRawText

    public String getRawText(String key)
                      throws BookException

  Throws:
    `BookException`

### getRawText

    protected String getRawText(DataEntry entry)

### getCardinality

    public int getCardinality()

  Description copied from interface: `Key`
  Returns the number of elements in this set (its cardinality). If this set contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

  Returns:
    the number of elements in this set (its cardinality).

### get

    public Key get(int index)

  Description copied from interface: `Key`
  Gets a key from a specific point in this list of children.

  Parameters:
    `index` - The index of the Key to retrieve
  Returns:
    The specified key

### indexOf

    public int indexOf(Key that)

  Description copied from interface: `Key`
  Reverse a Key into the position the key holds in the list of children

  Parameters:
    `that` - The Key to find
  Returns:
    The index of the key or < 0 if the key is not in the list

### activate

    public void activate(Lock lock)

  Description copied from interface: `Activatable`
  Called to indicate that the Book should initialize itself, and consume whatever system resources it needs to be able to respond to other queries.

  Parameters:
    `lock` - An attempt to ensure that only the Activator calls this method

### deactivate

    public void deactivate(Lock lock)

  Description copied from interface: `Activatable`
  Called to indicate that the Book should release whatever system resources it can to make way for other uses.

  Parameters:
    `lock` - An attempt to ensure that only the Activator calls this method

### checkActive

    protected boolean checkActive()

  Helper method so we can quickly activate ourselves on access

### isActive

    protected boolean isActive()

  Determine whether we are active.

### getIndex

    private DataIndex getIndex(long entry)
                        throws IOException

  Get the Index (that is offset and size) for an entry.

  Parameters:
    `entry` -
  Returns:
    the index of the entry
  Throws:
    `IOException`

### getEntry

    private DataEntry getEntry(String reply,
                               int index)
                        throws IOException

  Get the text for an indexed entry in the book.

  Parameters:
    `index` - the entry to get
  Returns:
    the text for the entry.
  Throws:
    `IOException`

### search

    private int search(String key)
                throws IOException

  Find a matching entry, returning it's index. Otherwise return < 0, such that (-pos - 1) gives the insertion index.

  Parameters:
    `key` -
  Returns:
    the match
  Throws:
    `IOException`

### external2internal

    private String external2internal(String externalKey)

  Convert the supplied key to something that can be understood by the module.

  Parameters:
    `externalKey` -
  Returns:
    the internal representation of the key.

### internal2external

    private String internal2external(String internalKey)

### normalizeForSearch

    private String normalizeForSearch(String internalKey)

### readObject

    private void readObject(ObjectInputStream is)
                     throws IOException,
                            ClassNotFoundException

  Serialization support.

  Parameters:
    `is` -
  Throws:
    `IOException`
    `ClassNotFoundException`

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