org.crosswire.jsword.book.sword
Class TreeNode

java.lang.Object
  extended by org.crosswire.jsword.book.sword.TreeNode
All Implemented Interfaces:
Serializable, Cloneable

 class TreeNode
extends Object
implements Cloneable, Serializable

A node that knows where the data is in the real file and where it is in relationship to other nodes.

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

Field Summary
private  int firstChild
          The offset of the first child record in the offset.
private  String name
          The name of this TreeNode.
private  int nextSibling
          The offset of the next sibling record in the offset.
private  int offset
          The offset of this TreeNode in the offset.
private  int parent
          The offset of the parent record in the offset.
private static long serialVersionUID
          Serialization ID
private  byte[] userData
          Optional, extra data associated with this TreeNode.
 
Constructor Summary
TreeNode()
          TreeNode default ctor.
TreeNode(int theOffset)
          Setup with the positions of data in the file
 
Method Summary
 TreeNode clone()
           
 int getFirstChild()
           
 String getName()
           
 int getNextSibling()
           
 int getOffset()
           
 int getParent()
           
 byte[] getUserData()
           
 boolean hasChildren()
           
 boolean hasNextSibling()
           
 void setFirstChild(int firstChild)
           
 void setName(String newName)
           
 void setNextSibling(int nextSibling)
           
 void setOffset(int newOffset)
           
 void setParent(int parent)
           
 void setUserData(byte[] theUserData)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offset

private int offset
The offset of this TreeNode in the offset.


name

private String name
The name of this TreeNode. Note, this is not the path. To get the path, one needs to traverse to the parent to construct the path.


userData

private byte[] userData
Optional, extra data associated with this TreeNode. For example, this is used to store offset and length for a raw genbook.


parent

private int parent
The offset of the parent record in the offset. Root nodes are indicated with a value of -1. That is, this TreeNode does not have a parent.


nextSibling

private int nextSibling
The offset of the next sibling record in the offset. Final siblings are indicated with a value of -1. That is, this TreeNode does not have a next sibling.


firstChild

private int firstChild
The offset of the first child record in the offset. Leaf nodes are indicated with a value of -1. That is, this TreeNode does not have any children.


serialVersionUID

private static final long serialVersionUID
Serialization ID

See Also:
Constant Field Values
Constructor Detail

TreeNode

TreeNode()
TreeNode default ctor.


TreeNode

TreeNode(int theOffset)
Setup with the positions of data in the file

Parameters:
theOffset -
Method Detail

getOffset

public int getOffset()
Returns:
the offset

setOffset

public void setOffset(int newOffset)
Parameters:
newOffset - the offset to set

getName

public String getName()
Returns:
the name

setName

public void setName(String newName)
Parameters:
newName - the name to set

getUserData

public byte[] getUserData()
Returns:
the userData

setUserData

public void setUserData(byte[] theUserData)
Parameters:
theUserData - the userData to set

getFirstChild

public int getFirstChild()
Returns:
the firstChild

hasChildren

public boolean hasChildren()
Returns:
whether there are children

setFirstChild

public void setFirstChild(int firstChild)
Parameters:
firstChild - the firstChild to set

getNextSibling

public int getNextSibling()
Returns:
the nextSibling

hasNextSibling

public boolean hasNextSibling()
Returns:
if there are more siblings

setNextSibling

public void setNextSibling(int nextSibling)
Parameters:
nextSibling - the nextSibling to set

getParent

public int getParent()
Returns:
the parent

setParent

public void setParent(int parent)
Parameters:
parent - the parent to set

clone

public TreeNode clone()
Overrides:
clone in class Object

Copyright ยจ 2003-2015