/** * Creates a new BoolFunctionClause. * * @param function The function invoked by the clause * @param children A list of SubClauses, to be given as arguments * to the function. If all the arguments are constant, the function * clause will be flagged as constant, and evaluated immediatelyx. * @throws DAP2ServerSideException Thrown if either 1) the function does not * accept the arguments given, or 2) the * clause is constant, and the attempt to evaluate it fails. */ protected BoolFunctionClause(BoolFunction function, List children) throws DAP2ServerSideException { function.checkArgs(children); this.function = function; this.children = children; this.constant = true; Iterator it = children.iterator(); while (it.hasNext()) { SubClause current = (SubClause) it.next(); current.setParent(this); if (!current.isConstant()) { constant = false; } } if (constant) { evaluate(); } }
/** * Generates a clause which invokes a function that returns a * boolean value. * * @see BoolFunctionClause */ public TopLevelClause newBoolFunctionClause(String functionName, List children) throws DAP2ServerSideException, NoSuchFunctionException { BoolFunction function = functionLibrary.getBoolFunction(functionName); if (function == null) { if (functionLibrary.getBTFunction(functionName) != null) { throw new NoSuchFunctionException ("The function " + functionName + "() does not return a " + "boolean value, and must be used in a comparison or " + "as an argument to another function."); } else { throw new NoSuchFunctionException ("This server does not support a " + functionName + "() function"); } } return new BoolFunctionClause(function, children); }