|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.numbering.DLNBase
public class 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 | |
---|---|
static int[] |
BIT_MASK
|
static int |
BITS_PER_UNIT
The default number of bits used per fixed size unit. |
Constructor Summary | |
---|---|
DLNBase()
|
|
DLNBase(byte prefixLen,
DLNBase previous,
short bitCnt,
VariableByteInput is)
|
|
DLNBase(DLNBase dln)
|
|
DLNBase(int units,
byte[] data,
int startOffset)
|
|
DLNBase(short bitCnt,
VariableByteInput is)
|
Method Summary | |
---|---|
void |
addLevelId(int levelId,
boolean isSubLevel)
Adds a new level to the node id, using levelId as initial value. |
int |
compareBits(DLNBase other,
int bitCount)
|
String |
debug()
|
void |
decrementLevelId()
|
boolean |
equals(DLNBase other)
|
static int |
getLengthInBytes(int units,
byte[] data,
int startOffset)
|
int |
getLevelCount(int startOffset)
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. |
int |
getSubLevelCount(int startOffset)
Returns the number of sub-levels in the id starting at startOffset. |
void |
incrementLevelId()
Increments the last level id by one. |
boolean |
isLevelSeparator(int index)
|
int |
lastLevelOffset()
Find the last level in the id and return its offset. |
void |
serialize(byte[] data,
int offset)
|
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 bytes used to encode it. |
boolean |
startsWith(DLNBase other)
Checks if the current DLN starts with the same bit sequence as other. |
String |
toBitString()
|
static String |
toBitString(byte b)
Returns a string showing the bit representation of the given byte. |
String |
toString()
|
int |
units()
Returns the number of units currently used to encode the id. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BITS_PER_UNIT
public static final int[] BIT_MASK
Constructor Detail |
---|
public DLNBase()
public DLNBase(DLNBase dln)
public DLNBase(int units, byte[] data, int startOffset)
public DLNBase(short bitCnt, VariableByteInput is) throws IOException
IOException
public DLNBase(byte prefixLen, DLNBase previous, short bitCnt, VariableByteInput is) throws IOException
IOException
Method Detail |
---|
public void setLevelId(int offset, int levelId)
offset
- levelId
- public void addLevelId(int levelId, boolean isSubLevel)
levelId
- initial valuepublic void incrementLevelId()
public void decrementLevelId()
public int getLevelId(int startBit)
startBit
-
public int units()
BITS_PER_UNIT
.
public int size()
public boolean isLevelSeparator(int index)
public int getLevelCount(int startOffset)
public int getSubLevelCount(int startOffset)
startOffset
-
public int[] getLevelIds()
public int lastLevelOffset()
public void serialize(byte[] data, int offset)
public static int getLengthInBytes(int units, byte[] data, int startOffset)
public boolean equals(DLNBase other)
public int compareBits(DLNBase other, int bitCount)
public boolean startsWith(DLNBase other)
other
- public String debug()
public String toString()
toString
in class Object
public String toBitString()
public static final String toBitString(byte b)
b
- the byte to display
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |