org.faktorips.runtime.formula
Class AbstractFormulaEvaluator

java.lang.Object
  extended by org.faktorips.runtime.formula.AbstractFormulaEvaluator
All Implemented Interfaces:
IFormulaEvaluator

public abstract class AbstractFormulaEvaluator
extends Object
implements IFormulaEvaluator

An abstract implementation of IFormulaEvaluator holding the product component generation or product component and handles the exceptions thrown by the evaluateInternal(String, Object...) method.

There is no method to set the compiled formula expression because the expressions have to be set by the IFormulaEvaluatorFactory while creating the evaluator.

Author:
dirmeier

Field Summary
static String COMPILED_EXPRESSION_XML_TAG
           
 
Constructor Summary
AbstractFormulaEvaluator(Object object, Map<String,String> nameToExpressionMap)
           
 
Method Summary
 Object evaluate(String formularName, Object... parameters)
          Evaluates a formula that was added through the builder
protected abstract  Object evaluateInternal(String formularName, Object... parameters)
          This method evaluates the formula with the given name and the specified parameters.
 Map<String,String> getNameToExpressionMap()
          Returns a defensive copy of the map of expressions/formulas held by this evaluator.
 Object getObject()
          Returns the product component generation or product component this is an evaluator for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPILED_EXPRESSION_XML_TAG

public static final String COMPILED_EXPRESSION_XML_TAG
See Also:
Constant Field Values
Constructor Detail

AbstractFormulaEvaluator

public AbstractFormulaEvaluator(Object object,
                                Map<String,String> nameToExpressionMap)
Method Detail

getObject

public Object getObject()
Description copied from interface: IFormulaEvaluator
Returns the product component generation or product component this is an evaluator for.

Specified by:
getObject in interface IFormulaEvaluator

evaluate

public Object evaluate(String formularName,
                       Object... parameters)
Evaluates a formula that was added through the builder

Specified by:
evaluate in interface IFormulaEvaluator
Parameters:
formularName - The name of the formula to evaluate
parameters - the parameters the formula requires when being evaluated
Returns:
the result of the evaluated formula
Throws:
IllegalArgumentException - if the formula signature is unknown

evaluateInternal

protected abstract Object evaluateInternal(String formularName,
                                           Object... parameters)
                                    throws Exception
This method evaluates the formula with the given name and the specified parameters. With the name and parameters you have the complete formula method signature. The order of the parameters is given by the formula signature.

Parameters:
formularName - name of the formula to evaluate
parameters - the parameters to evaluate the formula
Returns:
the return value of the evaluated formula
Throws:
Exception

getNameToExpressionMap

public Map<String,String> getNameToExpressionMap()
Returns a defensive copy of the map of expressions/formulas held by this evaluator.

Specified by:
getNameToExpressionMap in interface IFormulaEvaluator
Returns:
a map containing the expressions (with their names as keys) held by this formula evaluator


Copyright © 2015. All rights reserved.