Class CustomFunctionProvider
- java.lang.Object
-
- de.fzi.power.interpreter.calculator.expressionoasis.custom.CustomFunctionProvider
-
- All Implemented Interfaces:
FunctionProvider
public final class CustomFunctionProvider extends Object implements FunctionProvider
-
-
Constructor Summary
Constructors Constructor Description CustomFunctionProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Type
getFunctionType(String functionName, Type[] parameterTypes)
Gets the return type of the function.ValueObject
getFunctionValue(String functionName, ValueObject[] parameters)
Gets the return value of function.void
initialize(ExpressionContext expressionContext)
It initialize the Function provider with expression context and also gives a chance to pre-initialize any internal states for operationsboolean
supportsFunction(String functionName, Type[] parameterTypes)
Checks whether the this function provider supports any function or not.
-
-
-
Field Detail
-
POW
public static final String POW
The provided composite 'POW' function.- See Also:
- Constant Field Values
-
SQRT
public static final String SQRT
The provided composite 'SQRT' function.- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(ExpressionContext expressionContext)
Description copied from interface:FunctionProvider
It initialize the Function provider with expression context and also gives a chance to pre-initialize any internal states for operations- Specified by:
initialize
in interfaceFunctionProvider
- Parameters:
expressionContext
- Context of current expression evaluation process- Throws:
AssertionError
- In case the passedExpressionContext
is not aCustomExpressionContext
instance.
-
getFunctionType
public Type getFunctionType(String functionName, Type[] parameterTypes) throws ExpressionEngineException
Description copied from interface:FunctionProvider
Gets the return type of the function.- Specified by:
getFunctionType
in interfaceFunctionProvider
- Parameters:
functionName
- the name of the function.parameterTypes
- the types of the parameters- Returns:
Type.DOUBLE
in casesupportsFunction(String, Type[])
called with the given arguments returnstrue
, otherwisenull
.- Throws:
ExpressionEngineException
- if anything goes wrong
-
getFunctionValue
public ValueObject getFunctionValue(String functionName, ValueObject[] parameters) throws ExpressionEngineException
Gets the return value of function.- Specified by:
getFunctionValue
in interfaceFunctionProvider
- Parameters:
functionName
- the name of the functionparameters
- the parameters values of the function- Returns:
null
is returned in case the function denoted by the given name is not provided by this instance.- A
ValueObject
ofType.DOUBLE
is returned if none of the parameters is aMeasuredFactor
. - A
MeasuredValuesCompositeValueObject
is returned in any other case.
- Throws:
ExpressionEngineException
- if anything goes wrong
-
supportsFunction
public boolean supportsFunction(String functionName, Type[] parameterTypes) throws ExpressionEngineException
Description copied from interface:FunctionProvider
Checks whether the this function provider supports any function or not.- Specified by:
supportsFunction
in interfaceFunctionProvider
- Parameters:
functionName
- the name of the functionparameterTypes
- the type of parameters for the function- Returns:
true
if function provider supports the functionfalse
otherwise- Throws:
ExpressionEngineException
- if anything goes wrong
-
-