|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.numbering.DLNBase
org.exist.numbering.DLN
public class DLN
Represents a node id in the form of a dynamic level number (DLN). DLN's are hierarchical ids, which borrow from Dewey's decimal classification. Examples for node ids: 1, 1.1, 1.2, 1.2.1, 1.2.2, 1.3. In this case, 1 represents the root node, 1.1 is the first node on the second level, 1.2 the second, and so on. To support efficient insertion of new nodes between existing nodes, we use the concept of sublevel ids. Between two nodes 1.1 and 1.2, a new node can be inserted as 1.1/1, where the / is the sublevel separator. The / does not start a new level. 1.1 and 1.1/1 are thus on the same level of the tree. In the binary encoding, the '.' is represented by a 0-bit while '/' is written as a 1-bit.
Field Summary |
---|
Fields inherited from class org.exist.numbering.DLNBase |
---|
BIT_MASK, BITS_PER_UNIT |
Fields inherited from interface org.exist.numbering.NodeId |
---|
DOCUMENT_NODE, END_OF_DOCUMENT, IS_CHILD, IS_DESCENDANT, IS_SELF, LENGTH_NODE_ID_UNITS, ROOT_NODE |
Constructor Summary | |
---|---|
DLN()
Constructs a new DLN with a single id with value 1. |
|
DLN(byte prefixLen,
DLN previous,
short bitCnt,
VariableByteInput is)
|
|
DLN(DLN other)
Constructs a new DLN by copying the data of the passed DLN. |
|
DLN(int id)
Constructs a new DLN, using the passed id as its single level value. |
|
DLN(int units,
byte[] data,
int startOffset)
Reads a DLN from the given byte[]. |
|
DLN(short bitCnt,
VariableByteInput is)
Reads a DLN from the given VariableByteInput stream. |
|
DLN(String s)
Constructs a new DLN by parsing the string argument. |
Method Summary | |
---|---|
boolean |
after(NodeId other,
boolean isFollowing)
Returns true if the node represented by this node id comes after the argument node in document order. |
NodeId |
append(NodeId otherId)
|
boolean |
before(NodeId other,
boolean isPreceding)
Returns true if the node represented by this node id comes before the argument node in document order. |
int |
compareTo(NodeId otherId)
|
int |
compareTo(Object other)
|
int |
computeRelation(NodeId ancestor)
Computes the relationship of this node to the given potential ancestor node. |
boolean |
equals(NodeId other)
|
NodeId |
getChild(int child)
Returns a new NodeId representing the nth child node of this node. |
NodeId |
getParentId()
Returns a new DLN representing the parent of the current node. |
int |
getTreeLevel()
Returns the level within the document tree at which this node occurs. |
NodeId |
insertBefore()
|
NodeId |
insertNode(NodeId right)
|
boolean |
isChildOf(NodeId parent)
Is the current node a child node of the specified parent? |
boolean |
isDescendantOf(NodeId ancestor)
Is the current node id a descendant of the specified node? |
boolean |
isDescendantOrSelfOf(NodeId other)
|
boolean |
isSiblingOf(NodeId sibling)
|
static void |
main(String[] args)
|
NodeId |
newChild()
Returns a new DLN representing the first child node of this node. |
NodeId |
nextSibling()
Returns a new DLN representing the next following sibling of this node. |
NodeId |
precedingSibling()
Returns a new NodeId representing the prececing sibling of this node. |
NodeId |
write(NodeId prevId,
VariableByteOutputStream os)
Write the node id to a VariableByteOutputStream . |
void |
write(VariableByteOutputStream os)
Write the node id to a VariableByteOutputStream . |
Methods inherited from class org.exist.numbering.DLNBase |
---|
addLevelId, compareBits, debug, decrementLevelId, equals, getLengthInBytes, getLevelCount, getLevelId, getLevelIds, getSubLevelCount, incrementLevelId, isLevelSeparator, lastLevelOffset, serialize, setLevelId, size, startsWith, toBitString, toBitString, toString, units |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.exist.numbering.NodeId |
---|
serialize, size, units |
Constructor Detail |
---|
public DLN()
public DLN(String s)
s
- public DLN(int id)
id
- public DLN(DLN other)
other
- public DLN(int units, byte[] data, int startOffset)
units
- number of bits to readdata
- the byte[] to read fromstartOffset
- the start offset to start reading atpublic DLN(short bitCnt, VariableByteInput is) throws IOException
VariableByteInput
stream.
is
-
IOException
write(VariableByteOutputStream)
public DLN(byte prefixLen, DLN previous, short bitCnt, VariableByteInput is) throws IOException
IOException
Method Detail |
---|
public NodeId newChild()
newChild
in interface NodeId
public NodeId nextSibling()
nextSibling
in interface NodeId
public NodeId precedingSibling()
NodeId
precedingSibling
in interface NodeId
public NodeId getChild(int child)
NodeId
getChild
in interface NodeId
child
- the position of the child
public NodeId insertNode(NodeId right)
insertNode
in interface NodeId
public NodeId insertBefore()
insertBefore
in interface NodeId
public NodeId append(NodeId otherId)
append
in interface NodeId
public NodeId getParentId()
NodeId.DOCUMENT_NODE
. If the current node
is the document node, null is returned.
getParentId
in interface NodeId
NodeId.getParentId()
public boolean isDescendantOf(NodeId ancestor)
NodeId
isDescendantOf
in interface NodeId
ancestor
- node id of the potential ancestor
public boolean isDescendantOrSelfOf(NodeId other)
isDescendantOrSelfOf
in interface NodeId
public boolean isChildOf(NodeId parent)
NodeId
isChildOf
in interface NodeId
parent
- the parent node
public int computeRelation(NodeId ancestor)
NodeId
NodeId.IS_CHILD
, NodeId.IS_DESCENDANT
or NodeId.IS_SELF
. If the nodes are not in a ancestor-descendant relation,
the method returns -1.
computeRelation
in interface NodeId
ancestor
- the (potential) ancestor node to check against
public boolean isSiblingOf(NodeId sibling)
isSiblingOf
in interface NodeId
public int getTreeLevel()
getTreeLevel
in interface NodeId
public boolean equals(NodeId other)
equals
in interface NodeId
public int compareTo(Object other)
compareTo
in interface Comparable
public int compareTo(NodeId otherId)
compareTo
in interface NodeId
public boolean after(NodeId other, boolean isFollowing)
NodeId
after
in interface NodeId
other
- the node id to compare withisFollowing
- if true, return false for descendants of the current node
public boolean before(NodeId other, boolean isPreceding)
NodeId
before
in interface NodeId
other
- the node id to compare withisPreceding
- if true, return false for ancestors of the current node
public void write(VariableByteOutputStream os) throws IOException
VariableByteOutputStream
.
write
in interface NodeId
os
-
IOException
public NodeId write(NodeId prevId, VariableByteOutputStream os) throws IOException
NodeId
VariableByteOutputStream
. To save
storage space, only store those byte which are different from the previous node id.
write
in interface NodeId
prevId
- the node id previously written or nullos
- the output stream
IOException
- if there's a problem with the underlying output streampublic static void main(String[] args) throws IOException
IOException
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |