Package ru.ispras.fortress.expression
Class ExprTreeVisitorDefault
- java.lang.Object
-
- ru.ispras.fortress.expression.ExprTreeVisitorDefault
-
- All Implemented Interfaces:
ExprTreeVisitor
,TreeVisitor
- Direct Known Subclasses:
MapBasedPrinter.ExprTreeVisitor
public class ExprTreeVisitorDefault extends java.lang.Object implements ExprTreeVisitor
TheExprTreeVisitorDefault
abstract class provides a default implementation for theExprTreeVisitor
interface. This implementation does not perform any actions and does not collect any data. It stores the visitor status, which is by default set toStatus.OK
and is accessible via thegetStatus
andsetStatus
methods. All other methods defined by theExprTreeVisitor
interface and overridden by the class are empty. The class helps keep the size of other implementations of theExprTreeVisitor
interface to minimum when it is required to implement only a small number ofExprTreeVisitor
methods to perform some actions on the expression tree being visited.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ru.ispras.fortress.util.TreeVisitor
TreeVisitor.Status
-
-
Constructor Summary
Constructors Constructor Description ExprTreeVisitorDefault()
Constructs a default expression tree visitor and sets the visitor status toStatus.OK
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getOperandOrder()
Returns an array of operand indexes that specify in which order the operands of the currently visited operator should be visited.TreeVisitor.Status
getStatus()
Returns the current status of the visitor.void
onBegin()
Notifies that processing of a hierarchical structure has been started.void
onBindingBegin(NodeBinding node)
Starts visiting a binding node.void
onBindingEnd(NodeBinding node)
Finishes visiting a binding node.void
onBindingListEnd(NodeBinding node)
Notifies that visiting a bound variables list finished.void
onBoundVariableBegin(NodeBinding node, NodeVariable variable, Node value)
Notifies that visiting a bound variable has started.void
onBoundVariableEnd(NodeBinding node, NodeVariable variable, Node value)
Notifies that visiting a bound variable has finished.void
onEnd()
Notifies that processing of a hierarchical structure has been finished.void
onOperandBegin(NodeOperation operation, Node operand, int index)
Notifies that visiting an expression operand has started.void
onOperandEnd(NodeOperation operation, Node operand, int index)
Notifies that visiting an expression operand has finished.void
onOperationBegin(NodeOperation node)
Starts visiting an operation node.void
onOperationEnd(NodeOperation node)
Finishes visiting an operation node.void
onValue(NodeValue value)
Notifies that a value node has been visited.void
onVariable(NodeVariable variable)
Notifies that a variable node has been visited.void
setStatus(TreeVisitor.Status status)
Sets the current visitor status.
-
-
-
Method Detail
-
getStatus
public final TreeVisitor.Status getStatus()
Description copied from interface:TreeVisitor
Returns the current status of the visitor. The status guides further actions of the walker.- Specified by:
getStatus
in interfaceTreeVisitor
- Returns:
- Current visitor status.
-
setStatus
public final void setStatus(TreeVisitor.Status status)
Sets the current visitor status.- Parameters:
status
- New visitor status.- Throws:
java.lang.IllegalArgumentException
- if the parameter isnull
.
-
onBegin
public void onBegin()
Description copied from interface:TreeVisitor
Notifies that processing of a hierarchical structure has been started.- Specified by:
onBegin
in interfaceTreeVisitor
-
onEnd
public void onEnd()
Description copied from interface:TreeVisitor
Notifies that processing of a hierarchical structure has been finished.- Specified by:
onEnd
in interfaceTreeVisitor
-
onOperationBegin
public void onOperationBegin(NodeOperation node)
Description copied from interface:ExprTreeVisitor
Starts visiting an operation node.- Specified by:
onOperationBegin
in interfaceExprTreeVisitor
- Parameters:
node
- Operation node.
-
onOperationEnd
public void onOperationEnd(NodeOperation node)
Description copied from interface:ExprTreeVisitor
Finishes visiting an operation node.- Specified by:
onOperationEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Operation node.
-
getOperandOrder
public int[] getOperandOrder()
Description copied from interface:ExprTreeVisitor
Returns an array of operand indexes that specify in which order the operands of the currently visited operator should be visited. If the order is standard (i.e. [0..N-1]),null
is returned.- Specified by:
getOperandOrder
in interfaceExprTreeVisitor
- Returns:
- Array of operand indexes or
null
for the standard order.
-
onOperandBegin
public void onOperandBegin(NodeOperation operation, Node operand, int index)
Description copied from interface:ExprTreeVisitor
Notifies that visiting an expression operand has started.- Specified by:
onOperandBegin
in interfaceExprTreeVisitor
- Parameters:
operation
- Operation node.operand
- Operand node.index
- Operand index.
-
onOperandEnd
public void onOperandEnd(NodeOperation operation, Node operand, int index)
Description copied from interface:ExprTreeVisitor
Notifies that visiting an expression operand has finished.- Specified by:
onOperandEnd
in interfaceExprTreeVisitor
- Parameters:
operation
- Operation node.operand
- Operand node.index
- Operand index.
-
onValue
public void onValue(NodeValue value)
Description copied from interface:ExprTreeVisitor
Notifies that a value node has been visited.- Specified by:
onValue
in interfaceExprTreeVisitor
- Parameters:
value
- Value node.
-
onVariable
public void onVariable(NodeVariable variable)
Description copied from interface:ExprTreeVisitor
Notifies that a variable node has been visited.- Specified by:
onVariable
in interfaceExprTreeVisitor
- Parameters:
variable
- Variable node.
-
onBindingBegin
public void onBindingBegin(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Starts visiting a binding node.- Specified by:
onBindingBegin
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.
-
onBindingListEnd
public void onBindingListEnd(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variables list finished.- Specified by:
onBindingListEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Bounding node.
-
onBindingEnd
public void onBindingEnd(NodeBinding node)
Description copied from interface:ExprTreeVisitor
Finishes visiting a binding node.- Specified by:
onBindingEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.
-
onBoundVariableBegin
public void onBoundVariableBegin(NodeBinding node, NodeVariable variable, Node value)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variable has started. Bound value expression will be visited next as general expression.Bound variables are not visited at all.
- Specified by:
onBoundVariableBegin
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.variable
- Bound variable reference.value
- Bound value expression.
-
onBoundVariableEnd
public void onBoundVariableEnd(NodeBinding node, NodeVariable variable, Node value)
Description copied from interface:ExprTreeVisitor
Notifies that visiting a bound variable has finished.- Specified by:
onBoundVariableEnd
in interfaceExprTreeVisitor
- Parameters:
node
- Binding node.variable
- Bound variable reference.value
- Bound value expression.
-
-