public void addArgs(Iterable<ValueExpr> args) { for (ValueExpr arg : args) { addArg(arg); } }
public void addArgs(ValueExpr... args) { for (ValueExpr arg : args) { addArg(arg); } }
@Override public FunctionCall clone() { FunctionCall clone = (FunctionCall)super.clone(); clone.args = new ArrayList<ValueExpr>(getArgs().size()); for (ValueExpr arg : getArgs()) { clone.addArg(arg.clone()); } return clone; } }
private FunctionCall createFunctionCall(String uri, SimpleNode node, int minArgs, int maxArgs) throws VisitorException { FunctionCall functionCall = new FunctionCall(uri); int noOfArguments = node.jjtGetNumChildren(); if (noOfArguments > maxArgs || noOfArguments < minArgs) { throw new VisitorException( "unexpected number of arguments (" + noOfArguments + ") for function " + uri); } for (int i = 0; i < noOfArguments; i++) { Node argNode = node.jjtGetChild(i); functionCall.addArg((ValueExpr)argNode.jjtAccept(this, null)); } return functionCall; }
@Override public FunctionCall visit(ASTFunctionCall node, Object data) throws VisitorException { ValueConstant vc = (ValueConstant)node.getURI().jjtAccept(this, null); assert vc.getValue() instanceof IRI; FunctionCall functionCall = new FunctionCall(vc.getValue().toString()); for (ASTValueExpr argExpr : node.getArgList().getElements()) { functionCall.addArg((ValueExpr)argExpr.jjtAccept(this, null)); } return functionCall; }
@Override public Object visit(ASTFunctionCall node, Object data) throws VisitorException { ValueConstant uriNode = (ValueConstant)node.jjtGetChild(0).jjtAccept(this, null); IRI functionURI = (IRI)uriNode.getValue(); FunctionCall functionCall = new FunctionCall(functionURI.toString()); for (int i = 1; i < node.jjtGetNumChildren(); i++) { Node argNode = node.jjtGetChild(i); functionCall.addArg((ValueExpr)argNode.jjtAccept(this, null)); } return functionCall; }