Class BTreeOnHeap

java.lang.Object
io.github.jmcleodfoss.pst.ReadOnlyTreeModel
io.github.jmcleodfoss.pst.BTreeOnHeap
All Implemented Interfaces:
BTreeNode, TreeCustomNodeText, TreeModel

public class BTreeOnHeap
extends ReadOnlyTreeModel
The BTreeOnHeap class represents a B-tree contained on a heap defined by a node in the node B-tree.
See Also:
"[MS-PST] Outlook Personal Folders (.pst) File Format v20110608"
  • Field Details

    • logger

      protected static Logger logger
      Logger for debugging BTree-derived classes
    • children

      protected final BTreeNode[] children
      The children of this B-tree node. The children may be either intermediate nodes, which are themselves B-trees, or leaf nodes.
    • key

      protected final long key
      The key of this node is guaranteed to be the smallest key of any of its children.
  • Constructor Details

    • BTreeOnHeap

      public BTreeOnHeap​(HeapOnNode hon, PSTFile pstFile) throws IOException
      Construct a B-tree-on-heap structure with from the given heap-on-node structure and PST file object. This function is intended to create the root of the B-tree.
      Parameters:
      hon - The heap-on-node from which to derive this B-tree-on-heap.
      pstFile - The PST file's BTreeOnHeap.Header, input stream, etc.
      Throws:
      IOException - The PST file could not be read.
  • Method Details

    • actualSize

      public int actualSize​(io.github.jmcleodfoss.pst.BTree.Context<io.github.jmcleodfoss.pst.BTree,​BTreeLeaf> context)
      Obtain the actual size of the B-tree-on-heap object.
      Parameters:
      context - The context from which to create the B-tree-on-heap.
      Returns:
      The actual size of a B-tree-on-heap object for this B-tree-on-heap.
    • getData

      public static ByteBuffer getData​(Object o, HeapOnNode hon) throws UnsupportedEncodingException
      Obtain data for the given leaf node, or null if the given object is not a leaf node.
      Parameters:
      o - The node to retrieve the data for.
      hon - The heap-on-node from which the B-tree-on-heap is being built.
      Returns:
      A read-only ByteBuffer containing the data in the leaf node.
      Throws:
      UnsupportedEncodingException - The PST file could not be read.
    • getNodeText

      public String getNodeText()
      Retrieve text for this node.
      Returns:
      A String which may be used to describe the node, typically within a JTree display for the B-tree.
    • main

      public static void main​(String[] args)
      Test this class by displaying the first B-tree-on-heap in the given PST file.
      Parameters:
      args - The arguments to the test application.
    • getChild

      public Object getChild​(Object parent, int index)
      Obtain the given child of this node.
      Specified by:
      getChild in interface TreeModel
      Parameters:
      parent - The parent node to return the child of.
      index - The number of the child to return.
      Returns:
      The requested child node of the given parent node.
    • getChildCount

      public int getChildCount​(Object parent)
      Get the number of children of this node.
      Specified by:
      getChildCount in interface TreeModel
      Parameters:
      parent - The parent node to return the number of child nodes for.
      Returns:
      The number of children of the given parent node.
    • getIndexOfChild

      public int getIndexOfChild​(Object parent, Object child)
      Get the index of this child node in the given node.
      Specified by:
      getIndexOfChild in interface TreeModel
      Parameters:
      parent - The parent to search for child.
      child - The child node to look for in parent.
      Returns:
      The index of the given child in the given parent node, or -1 if it is not a child of parent.
    • getNodeTableModel

      public TableModel getNodeTableModel()
      Get a table model which can be used to describe this node.
      Specified by:
      getNodeTableModel in interface BTreeNode
      Returns:
      A TableModel describing this node.
    • getNodeText

      public String getNodeText​(Object value)
      Obtain text suitable for display in a JTree node.
      Specified by:
      getNodeText in interface TreeCustomNodeText
      Parameters:
      value - The node object to obtain display text for.
      Returns:
      A short text description of the node suitable for display in a JTree.
      See Also:
      TreeCustomNodeText
    • getRoot

      public Object getRoot()
      Get the root of the tree.
      Specified by:
      getRoot in interface TreeModel
      Returns:
      The root of this B-tree.
    • isLeaf

      public boolean isLeaf​(Object node)
      Is the given node a leaf node?
      Specified by:
      isLeaf in interface TreeModel
      Parameters:
      node - The node to check for leafiness.
      Returns:
      true if node is a leaf node, false if it is an intermediate node.
    • iterator

      public io.github.jmcleodfoss.pst.BTree.Iterator iterator()
      Provide an iterator over the leaves of the B-tree.
      Returns:
      An iterator over the leaves of the B-tree.
    • key

      public long key()
      Obtain the lookup key for this node.
      Specified by:
      key in interface BTreeNode
      Returns:
      The key for this node. This is guaranteed to be the smallest key of all leaf nodes descended from this node.
    • outputString

      @Deprecated public void outputString​(PrintStream out, StringBuilder prefix)
      Deprecated.
      Output this B-tree to the given stream. Each printed line begins with the String prefix, followed by a number of tabs which increases by one for each level This function is necessary because there can occasionally be too much information in a B-tree to use toString.
      Parameters:
      out - The PrintStream object to write the tree to.
      prefix - The prefix to use when printing this node.
    • rawData

      public ByteBuffer rawData​(io.github.jmcleodfoss.pst.BlockMap bbt, PSTFile pstFile) throws IOException
      Provide a mechanism to read the data from the node via a ByteBuffer.
      Specified by:
      rawData in interface BTreeNode
      Parameters:
      bbt - The PST file's block B-tree
      pstFile - The PST file's input data stream, header, etc.
      Returns:
      A ByteBuffer containing the data for this leaf node of a B-tree.
      Throws:
      IOException - The PST file could not be read.
    • toString

      public String toString()
      Provide a String which contains some information about this node. This is typically used for debugging.
      Overrides:
      toString in class Object
      Returns:
      A string describing this B-tree.