Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.exist.numbering
Class DLN

    java.lang.Object
      org.exist.numbering.DLNBase
          org.exist.numbering.DLN

All Implemented Interfaces:
  java.lang.Comparable, NodeId

public class DLN
extends DLNBase
implements NodeId

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`

Constructor Summary
`DLN()` Constructs a new DLN with a single id with value 1.
`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(java.lang.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.
`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(java.lang.Object other)`
`int` | `computeRelation(NodeId ancestor)` Computes the relationship of this node to the given potential ancestor node.
`boolean` | `equals(NodeId other)`
`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(java.lang.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.
`void` | `write(VariableByteOutputStream os)` Write the node id to a `VariableByteOutputStream`.

Methods inherited from class org.exist.numbering.DLNBase
`addLevelId, compareBits, debug, 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

### DLN

    public DLN()

  Constructs a new DLN with a single id with value 1.

### DLN

    public DLN(java.lang.String s)

  Constructs a new DLN by parsing the string argument. In the string, levels are separated by a '.', sublevels by a '/'. For example, '1.2/1' or '1.2/1.2' are valid ids.

Parameters:
  `s` -

### DLN

    public DLN(int id)

  Constructs a new DLN, using the passed id as its single level value.

Parameters:
  `id` -

### DLN

    public DLN(DLN other)

  Constructs a new DLN by copying the data of the passed DLN.

Parameters:
  `other` -

### DLN

    public DLN(int units,
               byte[] data,
               int startOffset)

  Reads a DLN from the given byte[].

Parameters:
  `units` - number of bits to read
  `data` - the byte[] to read from
  `startOffset` - the start offset to start reading at

### DLN

    public DLN(short bitCnt,
               VariableByteInput is)
        throws java.io.IOException

  Reads a DLN from the given `VariableByteInput` stream.

Parameters:
  `is` -
Throws:
  `java.io.IOException`
See Also:
  `write(VariableByteOutputStream)`

Method Detail

### newChild

    public NodeId newChild()

  Returns a new DLN representing the first child node of this node.

  Specified by:
    `newChild` in interface `NodeId`
  Returns:
    new child node id

### nextSibling

    public NodeId nextSibling()

  Returns a new DLN representing the next following sibling of this node.

  Specified by:
    `nextSibling` in interface `NodeId`
  Returns:
    new sibling node id.

### insertNode

    public NodeId insertNode(NodeId right)

  Specified by:
    `insertNode` in interface `NodeId`

### insertBefore

    public NodeId insertBefore()

  Specified by:
    `insertBefore` in interface `NodeId`

### getParentId

    public NodeId getParentId()

  Returns a new DLN representing the parent of the current node. If the current node is the root element of the document, the method returns `NodeId.DOCUMENT_NODE`. If the current node is the document node, null is returned.

  Specified by:
    `getParentId` in interface `NodeId`
  Returns:
    the id of the parent node or null if the current node is the document node.
  See Also:
    `NodeId.getParentId()`

### isDescendantOf

    public boolean isDescendantOf(NodeId ancestor)

  Description copied from interface: `NodeId`
  Is the current node id a descendant of the specified node?

  Specified by:
    `isDescendantOf` in interface `NodeId`
  Parameters:
    `ancestor` - node id of the potential ancestor
  Returns:
    true if the node id is a descendant of the given node, false otherwise

### isDescendantOrSelfOf

    public boolean isDescendantOrSelfOf(NodeId other)

  Specified by:
    `isDescendantOrSelfOf` in interface `NodeId`

### isChildOf

    public boolean isChildOf(NodeId parent)

  Description copied from interface: `NodeId`
  Is the current node a child node of the specified parent?

  Specified by:
    `isChildOf` in interface `NodeId`
  Parameters:
    `parent` - the parent node

### computeRelation

    public int computeRelation(NodeId ancestor)

  Description copied from interface: `NodeId`
  Computes the relationship of this node to the given potential ancestor node. The method returns an int constant indicating the relation. Possible relations are: `NodeId.IS_CHILD`, `NodeId.IS_DESCENDANT` or `NodeId.IS_SELF`. If the nodes are not in a ancestor-descendant relation, the method returns -1.

  Specified by:
    `computeRelation` in interface `NodeId`
  Parameters:
    `ancestor` - the (potential) ancestor node to check against
  Returns:
    an int value indicating the relation

### isSiblingOf

    public boolean isSiblingOf(NodeId sibling)

  Specified by:
    `isSiblingOf` in interface `NodeId`

### getTreeLevel

    public int getTreeLevel()

  Returns the level within the document tree at which this node occurs.

  Specified by:
    `getTreeLevel` in interface `NodeId`

### equals

    public boolean equals(NodeId other)

  Specified by:
    `equals` in interface `NodeId`

### compareTo

    public int compareTo(java.lang.Object other)

  Specified by:
    `compareTo` in interface `java.lang.Comparable`

### compareTo

    public int compareTo(NodeId otherId)

  Specified by:
    `compareTo` in interface `NodeId`

### after

    public boolean after(NodeId other,
                         boolean isFollowing)

  Description copied from interface: `NodeId`
  Returns true if the node represented by this node id comes after the argument node in document order. If isFollowing is set to true, the method behaves as if called to evaluate a following::* XPath select, i.e. it returns false for descendants of the current node.

  Specified by:
    `after` in interface `NodeId`
  Parameters:
    `other` -
    `isFollowing` -

### before

    public boolean before(NodeId other,
                          boolean isPreceding)

  Description copied from interface: `NodeId`
  Returns true if the node represented by this node id comes before the argument node in document order. If isPreceding is set to true, the method behaves as if called to evaluate a preceding::* XPath select, i.e. it returns false for ancestors of the current node.

  Specified by:
    `before` in interface `NodeId`
  Parameters:
    `other` -
    `isPreceding` -

### write

    public void write(VariableByteOutputStream os)
               throws java.io.IOException

  Write the node id to a `VariableByteOutputStream`.

  Specified by:
    `write` in interface `NodeId`
  Parameters:
    `os` -
  Throws:
    `java.io.IOException`

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) Wolfgang Meier. All rights reserved.