Class AbstractModularStandardOperationProcessor
- java.lang.Object
-
- de.gebit.integrity.operations.standard.AbstractModularStandardOperationProcessor
-
- All Implemented Interfaces:
StandardOperationProcessor
- Direct Known Subclasses:
DefaultModularStandardOperationProcessor
public abstract class AbstractModularStandardOperationProcessor extends Object implements StandardOperationProcessor
Abstract base implementation for a modular processor processing standard operations. This processor builds a kind of abstract syntax tree for evaluation of operations.- Author:
- Rene Schneider - initial API and implementation
-
-
Constructor Summary
Constructors Constructor Description AbstractModularStandardOperationProcessor()
Creates an instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addOperatorInfo(String anOperator, Class<? extends OperatorNode<?,?>> aNodeClass)
Adds an operator.protected OperatorNode<?,?>
createNode(Operation anOperation, String anOperator, Object aLeftOperand, Object aRightOperand)
Creates a new node.Object
executeOperation(StandardOperation anOperation)
Evaluates the givenStandardOperation
and returns the result object (not converted to any specific type).protected int
getOperatorPrecedence(String anOperator)
Determines the precedence (ordering) of the given operator.protected abstract void
initializeOperatorInfo()
Initializes all operators by calls toaddOperatorInfo(String, Class)
.protected OperatorNode<?,?>
parseOperation(StandardOperation anOperation)
Parses the given operation.
-
-
-
Method Detail
-
initializeOperatorInfo
protected abstract void initializeOperatorInfo()
Initializes all operators by calls toaddOperatorInfo(String, Class)
.
-
addOperatorInfo
protected void addOperatorInfo(String anOperator, Class<? extends OperatorNode<?,?>> aNodeClass)
Adds an operator.- Parameters:
anOperator
- the operator stringaNodeClass
- the node class representing this operator
-
executeOperation
public Object executeOperation(StandardOperation anOperation) throws UnexecutableException
Description copied from interface:StandardOperationProcessor
Evaluates the givenStandardOperation
and returns the result object (not converted to any specific type).- Specified by:
executeOperation
in interfaceStandardOperationProcessor
- Parameters:
anOperation
- the operation to execute- Returns:
- the result
- Throws:
UnexecutableException
- in case the operation cannot be executed (such as because we're running in Eclipse and don't have access to variable values)
-
parseOperation
protected OperatorNode<?,?> parseOperation(StandardOperation anOperation) throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
Parses the given operation.- Parameters:
anOperation
- the operation to parse- Returns:
- the AST representing the operation
- Throws:
SecurityException
IllegalArgumentException
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException
-
getOperatorPrecedence
protected int getOperatorPrecedence(String anOperator)
Determines the precedence (ordering) of the given operator.- Parameters:
anOperator
- the operator to evaluate- Returns:
- the numeric precedence (higher = evaluate first)
-
createNode
protected OperatorNode<?,?> createNode(Operation anOperation, String anOperator, Object aLeftOperand, Object aRightOperand) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
Creates a new node.- Parameters:
anOperator
- the operatoraLeftOperand
- the left operand (not evaluated)aRightOperand
- the right operand (not evaluated)- Returns:
- the node
- Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException
-
-