public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { if ( parameters.getParameterCount() != 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } try { final Type type = parameters.getType( 0 ); final Object value = parameters.getValue( 0 ); if ( ErrorType.TYPE.equals( type ) && value instanceof ErrorValue ) { return RETURN_TRUE; } } catch ( EvaluationException e ) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if ( parameterCount < 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } // we want error values propagated so we need to evaluate the parameter parameters.getValue( 0 ); final LValue raw = parameters.getRaw( 0 ); if ( raw instanceof ContextLookup ) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if (parameterCount < 1) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } final Object value = parameters.getValue(0); if(value instanceof Number) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); final Object value = parameters.getValue( 0 ); final Type type = parameters.getType( 0 ); final LValue raw = parameters.getRaw( 0 );
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { if ( parameters.getParameterCount() != 0 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } return RETURN_TRUE; } }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if (parameterCount < 1) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } final Type type1 = parameters.getType(0); if(type1.isFlagSet(Type.NUMERIC_TYPE)) { return RETURN_TRUE; } return RETURN_FALSE; }
protected long computeDays( final ParameterCallback parameters, final TypeRegistry typeRegistry ) throws EvaluationException { final Number date1 = typeRegistry.convertToNumber( parameters.getType( 0 ), parameters.getValue( 0 ) ); final Number date2 = typeRegistry.convertToNumber( parameters.getType( 1 ), parameters.getValue( 1 ) ); final BigDecimal dn1 = NumberUtil.performIntRounding( NumberUtil.getAsBigDecimal( date1 ) ); final BigDecimal dn2 = NumberUtil.performIntRounding( NumberUtil.getAsBigDecimal( date2 ) ); return dn2.longValue() - dn1.longValue(); }
@Test( expected = EvaluationException.class ) public void testNullKey() throws EvaluationException { when( parameters.getValue( eq( 0 ) ) ).thenReturn( null ); ResourceLookupFunction function = new ResourceLookupFunction(); function.evaluate( context, parameters ); }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { if ( parameters.getParameterCount() != 0 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } return RETURN_FALSE; } }
@Test( expected = EvaluationException.class ) public void testNullValue() throws EvaluationException { when( parameters.getValue( eq( 1 ) ) ).thenReturn( null ); ResourceLookupFunction function = new ResourceLookupFunction(); function.evaluate( context, parameters ); }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if ( parameterCount < 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } final Type type1 = parameters.getType( 0 ); final Object value1 = parameters.getValue( 0 ); if ( value1 instanceof Boolean || type1.isFlagSet( Type.LOGICAL_TYPE ) ) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if (parameterCount < 1) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } // we want error values propagated so we need to evaluate the parameter parameters.getValue(0); final LValue raw = parameters.getRaw(0); if (raw instanceof ContextLookup) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { if(parameters.getParameterCount() != 0) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } return RETURN_FALSE; } }
@Test public void testNoResourceFound() throws EvaluationException { when( parameters.getValue( eq( 0 ) ) ).thenReturn( "not found" ); ResourceLookupFunction function = new ResourceLookupFunction(); TypeValuePair result = function.evaluate( context, parameters ); String actual = String.valueOf( result.getValue() ); assertEquals( "key", actual ); }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if ( parameterCount < 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } final Type type1 = parameters.getType( 0 ); final Object value1 = parameters.getValue( 0 ); if ( type1 instanceof TextType || value1 instanceof String ) { return new TypeValuePair( TextType.TYPE, value1 ); } else { return EMPTY_STRING; } }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if ( parameterCount < 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } try { final Object value = parameters.getValue( 0 ); final LValue raw = parameters.getRaw( 0 ); if ( raw instanceof ContextLookup ) { if ( value == null ) { return RETURN_TRUE; } } } catch ( EvaluationException e ) { if ( e.getErrorValue().getErrorCode() == LibFormulaErrorValue.ERROR_NA ) { return RETURN_TRUE; } return RETURN_FALSE; } return RETURN_FALSE; } }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { if(parameters.getParameterCount() != 0) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } return RETURN_TRUE; } }
public TypeValuePair evaluate(final FormulaContext context, final ParameterCallback parameters) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if (parameterCount < 1) { throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); } final Type type1 = parameters.getType(0); final Object value1 = parameters.getValue(0); if(value1 instanceof Boolean || type1.isFlagSet(Type.LOGICAL_TYPE)) { return RETURN_TRUE; } return RETURN_FALSE; }
public TypeValuePair evaluate( FormulaContext context, ParameterCallback parameters ) throws EvaluationException { final int parameterCount = parameters.getParameterCount(); if ( parameterCount > 0 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } return new TypeValuePair( NumberType.GENERIC_NUMBER, PI_VALUE ); } }
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters ) throws EvaluationException { try { final int parameterCount = parameters.getParameterCount(); if ( parameterCount != 1 ) { throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE ); } final Type type1 = parameters.getType( 0 ); final Object value1 = parameters.getValue( 0 ); if ( type1.isFlagSet( Type.TEXT_TYPE ) || value1 instanceof String ) { return RETURN_TRUE; } return RETURN_FALSE; } catch ( EvaluationException e ) { return RETURN_FALSE; } }