|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exist.numbering.DLNBase
Base class representing a node id in the form of a dynamic level number (DLN).
See DLN. DLNBase handles the efficient binary encoding of node ids.
Level values are stored consecutively, using a fixed prefix free encoding. The number of
units to be used for encoding a single level value is dynamically adjusted. We start with
one unit and use its n - 1 lower bits. If the number exceeds the lower bits, we add another
unit and set the highest bit to 1. This process is repeated for larger numbers. As a result,
the first 1 bits of a level id indicate the number of fixed-size units used for encoding a level id.
We thus don't need separator bits between the units themselves.
| Field Summary | |
protected int |
bitIndex
|
protected byte[] |
bits
|
static int |
BITS_PER_UNIT
The default number of bits used per fixed size unit. |
protected static int[] |
PER_COMPONENT_SIZE
Lists the maximum number that can be encoded by a given number of units. |
protected static int |
UNIT_SHIFT
|
| Constructor Summary | |
|
DLNBase()
|
protected |
DLNBase(byte[] data,
int nbits)
|
|
DLNBase(DLNBase dln)
|
|
DLNBase(int units,
byte[] data,
int startOffset)
|
|
DLNBase(VariableByteInput is)
|
| Method Summary | |
void |
addLevelId(int levelId)
Adds a new level to the node id, using levelId as initial value. |
protected static int |
bitWidth(int units)
Calculates the number of bits available in a bit set that uses the given number of units. |
int |
compareTo(DLNBase other)
|
int |
compareTo(java.lang.Object obj)
|
java.lang.String |
debug()
|
int |
getLevelCount()
Returns the number of level in this id, which corresponds to the depth at which the node occurs within the node tree. |
int |
getLevelId(int startBit)
Returns the id starting at offset. |
int[] |
getLevelIds()
Return all level ids converted to int. |
protected static int |
getUnitsRequired(int levelId)
Calculates the minimum number of units that would be required to properly encode the given integer. |
void |
incrementLevelId()
Increments the last level id by one. |
protected int |
lastLevelOffset()
Find the last level in the id and return its offset. |
void |
serialize(byte[] data,
int offset)
|
protected void |
setCurrentLevelId(int levelId)
Set the level id for the last level that has been written. |
void |
setLevelId(int offset,
int levelId)
Set the level id which starts at offset to the given id value. |
int |
size()
Returns the size of this id by counting the bits used to encode it. |
boolean |
startsWith(DLNBase other)
|
java.lang.String |
toBitString()
|
java.lang.String |
toString()
|
byte |
units()
Returns the number of units currently used to encode the id. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int BITS_PER_UNIT
protected static final int[] PER_COMPONENT_SIZE
protected static final int UNIT_SHIFT
protected byte[] bits
protected int bitIndex
| Constructor Detail |
public DLNBase()
public DLNBase(DLNBase dln)
public DLNBase(int units,
byte[] data,
int startOffset)
protected DLNBase(byte[] data,
int nbits)
public DLNBase(VariableByteInput is)
throws java.io.IOException
| Method Detail |
public void setLevelId(int offset,
int levelId)
offset - levelId - public void addLevelId(int levelId)
levelId - initial valuepublic void incrementLevelId()
protected void setCurrentLevelId(int levelId)
levelId - public int getLevelId(int startBit)
startBit -
public byte units()
BITS_PER_UNIT.
public int size()
public int getLevelCount()
public int[] getLevelIds()
protected int lastLevelOffset()
public boolean startsWith(DLNBase other)
protected static int bitWidth(int units)
units -
protected static int getUnitsRequired(int levelId)
levelId - the integer to encode in the level id
public void serialize(byte[] data,
int offset)
public int compareTo(DLNBase other)
public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparablepublic java.lang.String debug()
public java.lang.String toString()
public java.lang.String toBitString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||