org.exist.numbering
Interface NodeId

All Superinterfaces:
java.lang.Comparable
All Known Implementing Classes:
DLN

public interface NodeId
extends java.lang.Comparable

Represents the internal id of a node within eXist. Basically, all stored nodes in eXist need to have an id that implements this interface. The id will be assigned according to used numbering scheme. From a given id, we can determine the relationship of the node it represents to any other node in the same document.


Field Summary
static NodeId DOCUMENT_NODE
          Static field representing the document node.
static NodeId END_OF_DOCUMENT
           
static int IS_CHILD
           
static int IS_DESCENDANT
           
static int IS_SELF
           
 
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 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 NodeId 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 ancestor)
           
 boolean isSiblingOf(NodeId sibling)
           
 NodeId newChild()
          Returns a new NodeId representing the first child node of this node.
 NodeId nextSibling()
          Returns a new NodeId representing the next following sibling of this node.
 void serialize(byte[] data, int offset)
          Serializes the node id to an array of bytes.
 int size()
          Returns the size (in bytes) of this node id.
 int units()
           
 void write(VariableByteOutputStream os)
          Write the node id to a VariableByteOutputStream.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

DOCUMENT_NODE

public static final NodeId DOCUMENT_NODE
Static field representing the document node.


END_OF_DOCUMENT

public static final NodeId END_OF_DOCUMENT

IS_CHILD

public static final int IS_CHILD
See Also:
Constant Field Values

IS_DESCENDANT

public static final int IS_DESCENDANT
See Also:
Constant Field Values

IS_SELF

public static final int IS_SELF
See Also:
Constant Field Values
Method Detail

newChild

public NodeId newChild()
Returns a new NodeId representing the first child node of this node. The returned id can be used for creating new nodes. The actual id of the first node might be different, depending on the implementation.

Returns:
new child node id

nextSibling

public NodeId nextSibling()
Returns a new NodeId representing the next following sibling of this node. The returned id can be used to create new sibling nodes. The actual id of the next sibling might be different, depending on the implementation.

Returns:
new sibling node id.

insertNode

public NodeId insertNode(NodeId right)

insertBefore

public NodeId insertBefore()

getParentId

public NodeId getParentId()
Returns a new NodeId representing the parent of the current node. If the parent is the document, the constant DOCUMENT_NODE will be returned. For the document itself, the parent id will be null.

Returns:
the id of the parent node or null if the current node is the document node.

after

public boolean after(NodeId other,
                     boolean isFollowing)
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.

Parameters:
other -
isFollowing -

before

public boolean before(NodeId other,
                      boolean isPreceding)
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.

Parameters:
other -
isPreceding -

isDescendantOf

public boolean isDescendantOf(NodeId ancestor)
Is the current node id a descendant of the specified node?

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 ancestor)

isChildOf

public boolean isChildOf(NodeId parent)
Is the current node a child node of the specified parent?

Parameters:
parent - the parent node

computeRelation

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

Parameters:
ancestor - the (potential) ancestor node to check against
Returns:
an int value indicating the relation

isSiblingOf

public boolean isSiblingOf(NodeId sibling)

getTreeLevel

public int getTreeLevel()
Returns the level within the document tree at which this node occurs.


compareTo

public int compareTo(NodeId other)

equals

public boolean equals(NodeId other)

size

public int size()
Returns the size (in bytes) of this node id. Depends on the concrete implementation.

Returns:
size

units

public int units()

serialize

public void serialize(byte[] data,
                      int offset)
Serializes the node id to an array of bytes. The first byte is written at offset.

Parameters:
data - the byte array to be filled
offset - offset into the array

write

public void write(VariableByteOutputStream os)
           throws java.io.IOException
Write the node id to a VariableByteOutputStream.

Parameters:
os -
Throws:
java.io.IOException


Copyright (C) Wolfgang Meier. All rights reserved.