Class ExpressionTreeElement
java.lang.Object
com.igormaznitsa.jcp.expression.ExpressionTreeElement
The class describes a wrapper around an expression item to be saved into an expression tree
- Author:
- Igor Maznitsa (igor.maznitsa@igormaznitsa.com)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaddSubTree(ExpressionTree tree) Add a tree as new child and make the maximum priority for itaddTreeElement(ExpressionTreeElement element) Add tree element with sorting operation depends on priority of the elementsvoidfillArguments(List<ExpressionTree> arguments) It fills children slots from a list containing expression treesintgetArity()Get arity for the element (I mean possible children number)getChildForIndex(int index) Get the child element for its index (the first is 0)getItem()Get the wrapped itemGet the parent for the elementintGet the current priority of the elementbooleanAllows to check that the element is EMPTY_SLOTbooleanisFull()It allows to check that all children slots have been filledvoidPost-processing after the tree is formed, the unary minus operation will be optimizedbooleanreplaceElement(ExpressionTreeElement oldOne, ExpressionTreeElement newOne) It replaces a child element
-
Field Details
-
EMPTY_SLOT
-
-
Method Details
-
isEmptySlot
public boolean isEmptySlot()Allows to check that the element is EMPTY_SLOT- Returns:
- true if the element is empty slot, false otherwise
-
getItem
-
getArity
public int getArity()Get arity for the element (I mean possible children number)- Returns:
- the arity, zero for elements without children
-
getParent
Get the parent for the element- Returns:
- the parent for the element or null if the element is the tree root
-
getPriority
public int getPriority()Get the current priority of the element- Returns:
- the priority
-
addSubTree
Add a tree as new child and make the maximum priority for it- Parameters:
tree- a tree to be added as a child, must not be null- Returns:
- it returns this
-
replaceElement
It replaces a child element- Parameters:
oldOne- the old expression element to be replaced (must not be null)newOne- the new expression element to be used instead the old one (must not be null)- Returns:
- true if the element was found and replaced, else false
-
getChildForIndex
Get the child element for its index (the first is 0)- Parameters:
index- the index of the needed child- Returns:
- the child or EMPTY_SLOT
- Throws:
ArrayIndexOutOfBoundsException- it will be thrown if an impossible index is being used- See Also:
-
addTreeElement
Add tree element with sorting operation depends on priority of the elements- Parameters:
element- the element to be added, must not be null- Returns:
- the element which should be used as the last for the current tree
-
isFull
public boolean isFull()It allows to check that all children slots have been filled- Returns:
- true if there is not any free child slot else false
-
fillArguments
It fills children slots from a list containing expression trees- Parameters:
arguments- the list containing trees to be used as children
-
postProcess
public void postProcess()Post-processing after the tree is formed, the unary minus operation will be optimized
-