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 TreeKeyIndex

    java.lang.Object
      org.crosswire.jsword.book.sword.TreeKeyIndex

All Implemented Interfaces:
  Activatable

    public class TreeKeyIndex

extends Object
implements Activatable

TreeKeyIndex reads Sword index files that are path based. Paths are of the form /a/b/c, and can be of any depth. The ultimate output of a TreeKeyIndex is the offset and length of a chunk of data in another file that can be read.

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

Field Summary
`private boolean` | `active`
`private SwordBookMetaData` | `bmd`
`private File` | `datFile`
`private RandomAccessFile` | `datRaf`
`private static String` | `EXTENSION_DATA`
`private static String` | `EXTENSION_INDEX`
`private File` | `idxFile`
`private RandomAccessFile` | `idxRaf`
`private static org.slf4j.Logger` | `log` The log stream

Constructor Summary
`TreeKeyIndex(SwordBookMetaData sbmd)` 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 void` | `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` | `getExpandedDataPath()`
`TreeNode` | `getFirstChild(TreeNode node)` Get the first child of the TreeNode.
`TreeNode` | `getNextSibling(TreeNode node)` Get the next sibling of the TreeNode.
`private int` | `getOffset(int index)` The idx file contains offsets into the dat file.
`TreeNode` | `getParent(TreeNode node)` Get the parent of the TreeNode.
`TreeNode` | `getRoot()`
`private TreeNode` | `getTreeNode(int offset)` Given an offset get the TreeNode from the dat file.

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

Field Detail

### EXTENSION_INDEX

    private static final String EXTENSION_INDEX

See Also:
  Constant Field Values

### EXTENSION_DATA

    private static final String EXTENSION_DATA

See Also:
  Constant Field Values

### bmd

    private SwordBookMetaData bmd

### idxFile

    private File idxFile

### datFile

    private File datFile

### idxRaf

    private RandomAccessFile idxRaf

### datRaf

    private RandomAccessFile datRaf

### active

    private boolean active

### log

    private static final org.slf4j.Logger log

  The log stream

Constructor Detail

### TreeKeyIndex

    public TreeKeyIndex(SwordBookMetaData sbmd)

  Simple ctor

  Parameters:
    `sbmd` -

Method Detail

### getRoot

    public TreeNode getRoot()
                     throws IOException

  Returns:
    the root TreeNode for the module.
  Throws:
    `IOException`

### getParent

    public TreeNode getParent(TreeNode node)
                       throws IOException

  Get the parent of the TreeNode.

  Parameters:
    `node` - the node being worked upon
  Returns:
    the parent node
  Throws:
    `IOException`

### getFirstChild

    public TreeNode getFirstChild(TreeNode node)
                           throws IOException

  Get the first child of the TreeNode.

  Parameters:
    `node` - the node being worked upon
  Returns:
    the first child node
  Throws:
    `IOException`

### getNextSibling

    public TreeNode getNextSibling(TreeNode node)
                            throws IOException

  Get the next sibling of the TreeNode.

  Parameters:
    `node` - the node being worked upon
  Returns:
    the next sibling node
  Throws:
    `IOException`

### getOffset

    private int getOffset(int index)
                   throws IOException

  The idx file contains offsets into the dat file.

  Parameters:
    `index` - the record id
  Returns:
    an offset into the dat file
  Throws:
    `IOException`

### getTreeNode

    private TreeNode getTreeNode(int offset)
                          throws IOException

  Given an offset get the TreeNode from the dat file.

  Parameters:
    `offset` - start of a TreeNode record in the dat file.
  Returns:
    the TreeNode
  Throws:
    `IOException`

### activate

    public final 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.

  Specified by:
    `activate` in interface `Activatable`
  Parameters:
    `lock` - An attempt to ensure that only the Activator calls this method

### deactivate

    public final 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.

  Specified by:
    `deactivate` in interface `Activatable`
  Parameters:
    `lock` - An attempt to ensure that only the Activator calls this method

### checkActive

    protected final void checkActive()

  Helper method so we can quickly activate ourselves on access

### getExpandedDataPath

    private String getExpandedDataPath()
                                throws BookException

  Throws:
    `BookException`

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