@Test public void testOR() { FunctionArgumentAttributeValue attr5 = null; try { attr5 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5)); } catch (Exception e) { fail("creating attribute e="+ e); } FunctionDefinitionLogical fd = (FunctionDefinitionLogical) StdFunctions.FD_OR; assertEquals(XACML3.ID_FUNCTION_OR, fd.getId()); assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeArgs().getId()); assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId()); assertFalse(fd.returnsBag()); arguments.add(attrT); arguments.add(attrF); ExpressionResult res = fd.evaluate(null, arguments); assertTrue(res.isOk()); Boolean resValue = (Boolean)res.getValue().getValue(); assertEquals(new Boolean(true), resValue); arguments.clear(); arguments.add(attrF); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertEquals(new Boolean(false), resValue); arguments.clear(); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertEquals(new Boolean(false), resValue); arguments.clear(); arguments.add(attrT); arguments.add(null); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertEquals(new Boolean(true), resValue); arguments.clear(); arguments.add(attrF); arguments.add(null); res = fd.evaluate(null, arguments); assertFalse(res.getStatus().isOk()); assertEquals( "function:or Got null argument", res.getStatus().getStatusMessage()); assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue()); arguments.clear(); arguments.add(attrF); arguments.add(attrF); arguments.add(attrF); arguments.add(attrF); arguments.add(attrF); res = fd.evaluate(null, arguments); assertTrue(res.isOk()); resValue = (Boolean)res.getValue().getValue(); assertEquals(new Boolean(false), resValue); arguments.clear(); arguments.add(attrF); arguments.add(attr5); res = fd.evaluate(null, arguments); assertFalse(res.getStatus().isOk()); assertEquals( "function:or Expected data type 'boolean' saw 'integer'", res.getStatus().getStatusMessage()); assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue()); arguments.clear(); arguments.add(null); res = fd.evaluate(null, arguments); assertFalse(res.getStatus().isOk()); assertEquals( "function:or Got null argument", res.getStatus().getStatusMessage()); assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue()); }
@Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { switch (operation) { case OR: if (arguments == null || arguments.size() == 0) { return ER_FALSE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_TRUE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_FALSE; case AND: if (arguments == null || arguments.size() == 0) { return ER_TRUE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == false) { return ER_FALSE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_TRUE; case N_OF: Integer argumentCountNeeded; int trueArgumentsSeen = 0; if (arguments == null || arguments.size() == 0) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got 0")); } try { if (arguments.get(0) == null) { return ER_TRUE; } if ( ! arguments.get(0).getStatus().isOk()) { return ExpressionResult.newError(getFunctionStatus(arguments.get(0).getStatus())); } if (arguments.get(0).isBag()) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected a simple value, saw a bag")); } AttributeValue<?> attributeValue = arguments.get(0).getValue(); if (attributeValue == null) { return ER_TRUE; } argumentCountNeeded = DataTypes.DT_INTEGER.convert(attributeValue.getValue()).intValue(); if (argumentCountNeeded == 0) { return ER_TRUE; } if (arguments.size() - 1 < argumentCountNeeded) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " + argumentCountNeeded + " arguments but only " + (arguments.size() - 1) + " arguments in list after the count")); } for (int i = 1; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if ((argument.getValue()) == true) { trueArgumentsSeen++; if (trueArgumentsSeen >= argumentCountNeeded) { return ER_TRUE; } } if ( (arguments.size() - i - 1) + trueArgumentsSeen < argumentCountNeeded) { return ER_FALSE; } } return ER_FALSE; } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } case NOT: if (arguments == null || arguments.size() != 1) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got " + ((arguments == null) ? "null" : arguments.size()) ) ); } try { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(0), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_FALSE; } else { return ER_TRUE; } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Logical function " + operation)); }
FunctionDefinitionLogical extends FunctionDefinitionHomogeneousSimple<Boolean,Boolean> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { switch (operation) { case OR: if (arguments == null || arguments.size() == 0) { return ER_FALSE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_TRUE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_FALSE; case AND: if (arguments == null || arguments.size() == 0) { return ER_TRUE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == false) { return ER_FALSE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_TRUE; case N_OF: Integer argumentCountNeeded; int trueArgumentsSeen = 0; if (arguments == null || arguments.size() == 0) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got 0")); } try { if (arguments.get(0) == null) { return ER_TRUE; } if ( ! arguments.get(0).getStatus().isOk()) { return ExpressionResult.newError(getFunctionStatus(arguments.get(0).getStatus())); } if (arguments.get(0).isBag()) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected a simple value, saw a bag")); } AttributeValue<?> attributeValue = arguments.get(0).getValue(); if (attributeValue == null) { return ER_TRUE; } argumentCountNeeded = DataTypes.DT_INTEGER.convert(attributeValue.getValue()).intValue(); if (argumentCountNeeded == 0) { return ER_TRUE; } if (arguments.size() - 1 < argumentCountNeeded) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " + argumentCountNeeded + " arguments but only " + (arguments.size() - 1) + " arguments in list after the count")); } for (int i = 1; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if ((argument.getValue()) == true) { trueArgumentsSeen++; if (trueArgumentsSeen >= argumentCountNeeded) { return ER_TRUE; } } if ( (arguments.size() - i - 1) + trueArgumentsSeen < argumentCountNeeded) { return ER_FALSE; } } return ER_FALSE; } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } case NOT: if (arguments == null || arguments.size() != 1) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got " + ((arguments == null) ? "null" : arguments.size()) ) ); } try { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(0), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_FALSE; } else { return ER_TRUE; } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Logical function " + operation)); } }
FunctionDefinitionLogical extends FunctionDefinitionHomogeneousSimple<Boolean,Boolean> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { switch (operation) { case OR: if (arguments == null || arguments.size() == 0) { return ER_FALSE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_TRUE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_FALSE; case AND: if (arguments == null || arguments.size() == 0) { return ER_TRUE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == false) { return ER_FALSE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_TRUE; case N_OF: Integer argumentCountNeeded; int trueArgumentsSeen = 0; if (arguments == null || arguments.size() == 0) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got 0")); } try { if (arguments.get(0) == null) { return ER_TRUE; } if ( ! arguments.get(0).getStatus().isOk()) { return ExpressionResult.newError(getFunctionStatus(arguments.get(0).getStatus())); } if (arguments.get(0).isBag()) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected a simple value, saw a bag")); } AttributeValue<?> attributeValue = arguments.get(0).getValue(); if (attributeValue == null) { return ER_TRUE; } argumentCountNeeded = DataTypes.DT_INTEGER.convert(attributeValue.getValue()).intValue(); if (argumentCountNeeded == 0) { return ER_TRUE; } if (arguments.size() - 1 < argumentCountNeeded) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " + argumentCountNeeded + " arguments but only " + (arguments.size() - 1) + " arguments in list after the count")); } for (int i = 1; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if ((argument.getValue()) == true) { trueArgumentsSeen++; if (trueArgumentsSeen >= argumentCountNeeded) { return ER_TRUE; } } if ( (arguments.size() - i - 1) + trueArgumentsSeen < argumentCountNeeded) { return ER_FALSE; } } return ER_FALSE; } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } case NOT: if (arguments == null || arguments.size() != 1) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got " + ((arguments == null) ? "null" : arguments.size()) ) ); } try { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(0), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_FALSE; } else { return ER_TRUE; } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Logical function " + operation)); } FunctionDefinitionLogical(Identifier idIn, OPERATION op); }
FunctionDefinitionLogical extends FunctionDefinitionHomogeneousSimple<Boolean,Boolean> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { switch (operation) { case OR: if (arguments == null || arguments.size() == 0) { return ER_FALSE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_TRUE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_FALSE; case AND: if (arguments == null || arguments.size() == 0) { return ER_TRUE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == false) { return ER_FALSE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_TRUE; case N_OF: Integer argumentCountNeeded; int trueArgumentsSeen = 0; if (arguments == null || arguments.size() == 0) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got 0")); } try { if (arguments.get(0) == null) { return ER_TRUE; } if ( ! arguments.get(0).getStatus().isOk()) { return ExpressionResult.newError(getFunctionStatus(arguments.get(0).getStatus())); } if (arguments.get(0).isBag()) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected a simple value, saw a bag")); } AttributeValue<?> attributeValue = arguments.get(0).getValue(); if (attributeValue == null) { return ER_TRUE; } argumentCountNeeded = DataTypes.DT_INTEGER.convert(attributeValue.getValue()).intValue(); if (argumentCountNeeded == 0) { return ER_TRUE; } if (arguments.size() - 1 < argumentCountNeeded) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " + argumentCountNeeded + " arguments but only " + (arguments.size() - 1) + " arguments in list after the count")); } for (int i = 1; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if ((argument.getValue()) == true) { trueArgumentsSeen++; if (trueArgumentsSeen >= argumentCountNeeded) { return ER_TRUE; } } if ( (arguments.size() - i - 1) + trueArgumentsSeen < argumentCountNeeded) { return ER_FALSE; } } return ER_FALSE; } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } case NOT: if (arguments == null || arguments.size() != 1) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got " + ((arguments == null) ? "null" : arguments.size()) ) ); } try { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(0), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_FALSE; } else { return ER_TRUE; } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Logical function " + operation)); } FunctionDefinitionLogical(Identifier idIn, OPERATION op); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments); }
FunctionDefinitionLogical extends FunctionDefinitionHomogeneousSimple<Boolean,Boolean> { @Override public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) { switch (operation) { case OR: if (arguments == null || arguments.size() == 0) { return ER_FALSE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_TRUE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_FALSE; case AND: if (arguments == null || arguments.size() == 0) { return ER_TRUE; } try { for (int i = 0; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == false) { return ER_FALSE; } } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } return ER_TRUE; case N_OF: Integer argumentCountNeeded; int trueArgumentsSeen = 0; if (arguments == null || arguments.size() == 0) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got 0")); } try { if (arguments.get(0) == null) { return ER_TRUE; } if ( ! arguments.get(0).getStatus().isOk()) { return ExpressionResult.newError(getFunctionStatus(arguments.get(0).getStatus())); } if (arguments.get(0).isBag()) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected a simple value, saw a bag")); } AttributeValue<?> attributeValue = arguments.get(0).getValue(); if (attributeValue == null) { return ER_TRUE; } argumentCountNeeded = DataTypes.DT_INTEGER.convert(attributeValue.getValue()).intValue(); if (argumentCountNeeded == 0) { return ER_TRUE; } if (arguments.size() - 1 < argumentCountNeeded) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected " + argumentCountNeeded + " arguments but only " + (arguments.size() - 1) + " arguments in list after the count")); } for (int i = 1; i < arguments.size(); i++) { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(i), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if ((argument.getValue()) == true) { trueArgumentsSeen++; if (trueArgumentsSeen >= argumentCountNeeded) { return ER_TRUE; } } if ( (arguments.size() - i - 1) + trueArgumentsSeen < argumentCountNeeded) { return ER_FALSE; } } return ER_FALSE; } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } case NOT: if (arguments == null || arguments.size() != 1) { return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 1 argument, got " + ((arguments == null) ? "null" : arguments.size()) ) ); } try { ConvertedArgument<Boolean> argument = new ConvertedArgument<Boolean>(arguments.get(0), this.getDataTypeArgs(), false); if ( ! argument.isOk()) { return ExpressionResult.newError(getFunctionStatus(argument.getStatus())); } if (argument.getValue() == true) { return ER_FALSE; } else { return ER_TRUE; } } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message)); } } return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Could not evaluate Logical function " + operation)); } FunctionDefinitionLogical(Identifier idIn, OPERATION op); @Override ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments);  }