rossi.fstools.fs.reiserfs
Class Key

java.lang.Object
  extended byrossi.fstools.fs.reiserfs.Key
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, DiskStructure, InodePtr
Direct Known Subclasses:
KeyV1, KeyV2

public abstract class Key
extends java.lang.Object
implements DiskStructure, InodePtr, java.lang.Comparable, java.lang.Cloneable

Representation of a key. There are two versions, KeyV1 and KeyV2.

The two versions differ in the way they represent offset and type on disk.


Field Summary
static int KEY_FORMAT_3_5
          Indicates Key format 3.5
static int KEY_FORMAT_3_6
          Indicates Key format 3.6
protected  long objectId
           
protected  long offset
           
protected  long parentDirId
           
protected  int type
           
static int TYPE_DIRECT
          Type indicating Direct Item.
static int TYPE_DIRENTRY
          Type indicating Directory Item.
static int TYPE_INDIRECT
          Type indicating Indirect Item.
static int TYPE_MAXTYPE
           
static int TYPE_STAT_DATA
          Type indicating Stat Item.
 
Constructor Summary
Key()
           
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object other)
          Defines the sort order of Keys.
static Key createKeyFromBuffer(byte[] buffer, int blkoffset)
          Creates a key object given a buffer.
 int getDataSize()
          Get the size in bytes of the structure.
 long getObjectId()
          Get the identifier for this object.
 long getOffset()
          Get the offset.
 long getParentDirId()
          Get the identifier for the parent directory.
 int getType()
          Get the item type.
 void setObjectId(long aObjectId)
           
 void setOffset(long aOffset)
           
 void setParentDirId(long aParentDirId)
           
 void setType(int aType)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface rossi.fstools.fs.DiskStructure
loadFromBuffer
 

Field Detail

KEY_FORMAT_3_5

public static final int KEY_FORMAT_3_5
Indicates Key format 3.5

See Also:
Constant Field Values

KEY_FORMAT_3_6

public static final int KEY_FORMAT_3_6
Indicates Key format 3.6

See Also:
Constant Field Values

TYPE_STAT_DATA

public static final int TYPE_STAT_DATA
Type indicating Stat Item.

See Also:
Constant Field Values

TYPE_INDIRECT

public static final int TYPE_INDIRECT
Type indicating Indirect Item.

See Also:
Constant Field Values

TYPE_DIRECT

public static final int TYPE_DIRECT
Type indicating Direct Item.

See Also:
Constant Field Values

TYPE_DIRENTRY

public static final int TYPE_DIRENTRY
Type indicating Directory Item.

See Also:
Constant Field Values

TYPE_MAXTYPE

public static final int TYPE_MAXTYPE
See Also:
Constant Field Values

parentDirId

protected long parentDirId

objectId

protected long objectId

offset

protected long offset

type

protected int type
Constructor Detail

Key

public Key()
Method Detail

getDataSize

public int getDataSize()
Description copied from interface: DiskStructure
Get the size in bytes of the structure. For variable length sturctures this may represent the minimum length rather than the actual length.

Specified by:
getDataSize in interface DiskStructure
Returns:
the size of the structure.

getParentDirId

public long getParentDirId()
Get the identifier for the parent directory.

Returns:
parent id.

setParentDirId

public void setParentDirId(long aParentDirId)

getObjectId

public long getObjectId()
Get the identifier for this object.

Returns:
identifier.

setObjectId

public void setObjectId(long aObjectId)

getOffset

public long getOffset()
Get the offset. When an object is split across multiple items, this indicates the byte offset within the object that this key represents

Returns:
the offset.

setOffset

public void setOffset(long aOffset)

getType

public int getType()
Get the item type. This will control which Item subclass is used to represent the item.

Returns:
item type.

setType

public void setType(int aType)

createKeyFromBuffer

public static Key createKeyFromBuffer(byte[] buffer,
                                      int blkoffset)
                               throws FsException
Creates a key object given a buffer. Trys to first create a 3.6 format key (KeyV2), and if that fails, then trys to make a 3.5 key (KeyV1)

Throws:
FsException

compareTo

public int compareTo(java.lang.Object other)
Defines the sort order of Keys. Keys are stored in the B-tree in sorted order, so finding an item relys on this order. Keys are first ordered by parent ID, then by object Id, then by offset, and lastly type.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
-1 if other < this, 1 if other > this, 0 if other == this

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException