rossi.fstools.fs.reiserfs
Class LeafNode

java.lang.Object
  extended byrossi.fstools.fs.reiserfs.FBlock
      extended byrossi.fstools.fs.reiserfs.LeafNode
All Implemented Interfaces:
DiskStructure

public class LeafNode
extends FBlock

Representation of an leaf node of the B+Tree.

This structure is the container for Items in the filesystem.

Following the block header (at offset 0x18), is an array of N ItemHeaders, followed by some free space. The from the end of the block working backwards is an array of items. The item headers need to be read first to determine where the item bodies are.


Field Summary
protected  ItemHead[] itemHeaders
           
 
Fields inherited from class rossi.fstools.fs.reiserfs.FBlock
blocknum, freeSpace, level, numItems, parent, reserved, rightKey, sb
 
Constructor Summary
LeafNode(ReiserSuperBlock sb, int blocknum)
          Create a new leaf node
 
Method Summary
 Item getItem(byte[] buffer, int offset, ItemHead ih)
          Gets an item from this block given the item header.
 Item getItem(byte[] buffer, int offset, Key key)
          Returns the item matching the given key, or the next one greater.
 ItemHead[] getItemHeaders()
          Get an array of all the ItemHeaders in this leaf.
 void loadFromBuffer(byte[] buffer, int blkoffset)
          Load this structure from disk.
 void setItemHeaders(ItemHead[] aItemHeaders)
           
 
Methods inherited from class rossi.fstools.fs.reiserfs.FBlock
createFromBuffer, getBlockHeaderSize, getBlockNum, getDataSize, getFreeSpace, getLevel, getNumItems, getParent, getReserved, getRightKey, getSuperBlock, setFreeSpace, setLevel, setNumItems, setParent, setReserved, setRightKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemHeaders

protected ItemHead[] itemHeaders
Constructor Detail

LeafNode

public LeafNode(ReiserSuperBlock sb,
                int blocknum)
Create a new leaf node

Parameters:
sb - a ReiserSuperBlock for this filesystem.
blocknum - number of this block
Method Detail

getItemHeaders

public ItemHead[] getItemHeaders()
Get an array of all the ItemHeaders in this leaf.

Returns:
ItemHead[]

setItemHeaders

public void setItemHeaders(ItemHead[] aItemHeaders)

getItem

public Item getItem(byte[] buffer,
                    int offset,
                    Key key)
             throws FsException
Returns the item matching the given key, or the next one greater.

Returns:
the requested Item
Throws:
FsException

getItem

public Item getItem(byte[] buffer,
                    int offset,
                    ItemHead ih)
             throws FsException
Gets an item from this block given the item header.

Parameters:
buffer - contains this block at offset.
offset - points to the start of this block.
Returns:
the requested item
Throws:
FsException

loadFromBuffer

public void loadFromBuffer(byte[] buffer,
                           int blkoffset)
                    throws FsException
Description copied from class: FBlock
Load this structure from disk.

Specified by:
loadFromBuffer in interface DiskStructure
Overrides:
loadFromBuffer in class FBlock
Throws:
FsException - if a parse error occurs
See Also:
DiskStructure.loadFromBuffer(byte[], int)