Package sk.iway.iwcm.database.nestedsets
Interface Node<T extends NodeInfo>
- All Superinterfaces:
NodeInfo
- All Known Implementing Classes:
JpaNode
A node in a nested set tree.
-
Method Summary
Modifier and TypeMethodDescriptionAdds a node as the last child of this node.void
delete()
Deletes the node and all its descendants from the tree.Gets all ancestors of this node.Gets the children children of the node (direct descendants).Gets the descendants of this node.getDescendants
(int depth) Gets descendants of this node, up to a certain depth.Gets the first child node of this node.Gets the last child node of this node.Gets the parent node of this node.boolean
Tests if the node has any children.boolean
Tests if the node has a parent.boolean
isDescendantOf
(Node<T> other) Determines if this node is a descendant of the given node.boolean
isRoot()
Tests if this node is a root node.boolean
isValid()
Tests whether the node is a valid node.void
moveAsFirstChildOf
(Node<T> dest) Moves this node in the tree, positioning it as the first child of the given node.void
moveAsLastChildOf
(Node<T> dest) Moves this node in the tree, positioning it as the last child of the given node.void
moveAsNextSiblingOf
(Node<T> dest) Moves this node in the tree, positioning it as the successive sibling of the given node.void
moveAsPrevSiblingOf
(Node<T> dest) Moves this node as the previous sibling of the given node.unwrap()
Unwraps the node, returning the wrapped object.Methods inherited from interface sk.iway.iwcm.database.nestedsets.NodeInfo
getId, getLeftValue, getLevel, getRightValue, getRootValue, setLeftValue, setLevel, setRightValue, setRootValue
-
Method Details
-
moveAsLastChildOf
Moves this node in the tree, positioning it as the last child of the given node.- Parameters:
dest
-
-
moveAsFirstChildOf
Moves this node in the tree, positioning it as the first child of the given node.- Parameters:
dest
-
-
moveAsNextSiblingOf
Moves this node in the tree, positioning it as the successive sibling of the given node.- Parameters:
dest
-
-
moveAsPrevSiblingOf
Moves this node as the previous sibling of the given node.- Parameters:
dest
-
-
getChildren
Gets the children children of the node (direct descendants).- Returns:
- The children of the node.
-
getDescendants
Gets descendants of this node, up to a certain depth.- Parameters:
depth
-- Returns:
- The descendants of the node, up to the specified depth.
-
getDescendants
Gets the descendants of this node.- Returns:
- The descendants of this node.
-
getAncestors
Gets all ancestors of this node.- Returns:
- The ancestors of the node.
-
addChild
Adds a node as the last child of this node.- Parameters:
child
- The child to add.- Returns:
- The newly inserted child node.
-
getParent
Gets the parent node of this node.- Returns:
- The parent node or NULL if there is no parent node.
-
getFirstChild
Gets the first child node of this node.- Returns:
- The first child node of this node.
-
getLastChild
Gets the last child node of this node.- Returns:
- The last child node.
-
unwrap
T unwrap()Unwraps the node, returning the wrapped object.- Returns:
- The wrapped object.
-
delete
void delete()Deletes the node and all its descendants from the tree. -
isRoot
boolean isRoot()Tests if this node is a root node.- Returns:
- TRUE if this node is a root node, FALSE otherwise.
-
hasParent
boolean hasParent()Tests if the node has a parent. If it does not have a parent, it is a root node.- Returns:
- TRUE if this node has a parent node, FALSE otherwise.
-
hasChildren
boolean hasChildren()Tests if the node has any children.- Returns:
- TRUE if the node has children, FALSE otherwise.
-
isValid
boolean isValid()Tests whether the node is a valid node. A valid node is a node with a valid position in the tree, represented by its left, right and level values.- Returns:
- TRUE if the node is valid, FALSE otherwise.
-
isDescendantOf
Determines if this node is a descendant of the given node.- Returns:
- TRUE if this node is a descendant of the given node, FALSE otherwise.
-