Package com.exasol.util
Interface TreeNode
-
- All Known Subinterfaces:
BooleanExpression,Function,ValueExpression
- All Known Implementing Classes:
AbstractBooleanExpression,AbstractBottomUpTreeNode,AbstractFunction,AbstractTree,AbstractTreeNode,AbstractValueExpression,And,BigDecimalLiteral,BinaryArithmeticExpression,BooleanLiteral,BooleanTerm,ColumnReference,Comparison,DefaultValue,DoubleLiteral,ExasolFunction,ExasolUdf,ExpressionTerm,FloatLiteral,IntegerLiteral,LongLiteral,Not,NullLiteral,Or,StringLiteral,UnnamedPlaceholder
public interface TreeNodeThis class represents a node in a tree structure.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddChild(TreeNode child)Add a child node below this node.TreeNodegetChild(int index)Get child node by position in the list of siblings.List<TreeNode>getChildren()Get all child nodes of this nodeTreeNodegetParent()Get the parent of this nodeTreeNodegetRoot()Get the root of the treebooleanisChild()Check whether this node is a child nodebooleanisFirstSibling()Check whether a child is the first in the list of siblingsbooleanisRoot()Check whether this node is the root of the tree.booleanisSibling(TreeNode node)Check whether this node is a sibling of the second node.voidsetParent(TreeNode parent)Set a parent for this node.
-
-
-
Method Detail
-
getRoot
TreeNode getRoot()
Get the root of the tree- Returns:
- root node
-
getParent
TreeNode getParent()
Get the parent of this node- Returns:
- parent node
-
addChild
void addChild(TreeNode child)
Add a child node below this node. Children are registered in the order in which they are added.Important: this also automatically creates a link in the opposite direction. All implementations must adhere to this rule.
- Parameters:
child- child node
-
getChild
TreeNode getChild(int index)
Get child node by position in the list of siblings. The position depends on the order in which the children were added.- Parameters:
index- position in the list of siblings- Returns:
- child node at position
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index ≥ size())
-
isRoot
boolean isRoot()
Check whether this node is the root of the tree.- Returns:
trueif this node is the root
-
isChild
boolean isChild()
Check whether this node is a child node- Returns:
trueif the node is a child of another node
-
isFirstSibling
boolean isFirstSibling()
Check whether a child is the first in the list of siblings- Returns:
trueif the child is the first in the list of siblings
-
isSibling
boolean isSibling(TreeNode node)
Check whether this node is a sibling of the second node.- Parameters:
node- second node- Returns:
- true if two nodes are siblings
-
setParent
void setParent(TreeNode parent)
Set a parent for this node.- Parameters:
parent- a node to set as a parent
-
-