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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOperatorInfo(String anOperator, Class<? extends OperatorNode<?, ?>> aNodeClass) Adds an operator.protected OperatorNode<?, ?> createNode(Operation anOperation, String anOperator, Object aLeftOperand, Object aRightOperand) Creates a new node.executeOperation(StandardOperation anOperation) Evaluates the givenStandardOperationand returns the result object (not converted to any specific type).protected intgetOperatorPrecedence(String anOperator) Determines the precedence (ordering) of the given operator.protected abstract voidInitializes all operators by calls toaddOperatorInfo(String, Class).protected OperatorNode<?, ?> parseOperation(StandardOperation anOperation) Parses the given operation.
-
Constructor Details
-
AbstractModularStandardOperationProcessor
public AbstractModularStandardOperationProcessor()Creates an instance.
-
-
Method Details
-
initializeOperatorInfo
protected abstract void initializeOperatorInfo()Initializes all operators by calls toaddOperatorInfo(String, Class). -
addOperatorInfo
Adds an operator.- Parameters:
anOperator- the operator stringaNodeClass- the node class representing this operator
-
executeOperation
Description copied from interface:StandardOperationProcessorEvaluates the givenStandardOperationand returns the result object (not converted to any specific type).- Specified by:
executeOperationin 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:
SecurityExceptionIllegalArgumentExceptionNoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetException
-
getOperatorPrecedence
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:
SecurityExceptionNoSuchMethodExceptionIllegalArgumentExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetException
-