description = new DefaultFunctionDescription( function.getCanonicalName() ); } else { description = (FunctionDescription) descr; categoryFunctions.add( cat, function.getCanonicalName() ); functionMetaData.put( function.getCanonicalName(), description ); functions.put( function.getCanonicalName(), className ); categories.add( cat );
public TypeValuePair evaluate() throws EvaluationException { // First, grab the parameters and their types. final FormulaContext context = getContext(); // And if everything is ok, compute the stuff .. if ( function == null ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_INVALID_FUNCTION_VALUE ); } try { return function.evaluate( context, new FormulaParameterCallback( this ) ); } catch ( EvaluationException e ) { throw e; } catch ( Exception e ) { logger.error( "Unexpected exception while evaluating", e ); throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE ); } }
if (descr instanceof FunctionDescription == false) description = new DefaultFunctionDescription(function.getCanonicalName()); categoryFunctions.add(cat, function.getCanonicalName()); functionMetaData.put (function.getCanonicalName(), description); functions.put(function.getCanonicalName(), className); categories.add(cat);
public TypeValuePair evaluate() throws EvaluationException { // First, grab the parameters and their types. final FormulaContext context = getContext(); // And if everything is ok, compute the stuff .. if (function == null) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_FUNCTION_VALUE); } try { return function.evaluate(context, new FormulaParameterCallback(this)); } catch (EvaluationException e) { throw e; } catch (Exception e) { logger.error("Unexpected exception while evaluating", e); throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE); } }
@Test public void testFunctionMetaData() { DefaultFormulaContext ctx = new DefaultFormulaContext(); FunctionRegistry functionRegistry = ctx.getFunctionRegistry(); for ( final String name : functionRegistry.getFunctionNames() ) { FunctionDescription metaData = functionRegistry.getMetaData( name ); Assert.assertEquals( name, metaData.getCanonicalName() ); Assert.assertEquals( name, functionRegistry.createFunction( name ).getCanonicalName() ); } } }