Search in sources :

Example 1 with FunctionCall

use of org.eclipse.rdf4j.query.algebra.FunctionCall in project rdf4j by eclipse.

the class QueryModelBuilder method visit.

@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;
}
Also used : IRI(org.eclipse.rdf4j.model.IRI) ASTValueExpr(org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr) ValueConstant(org.eclipse.rdf4j.query.algebra.ValueConstant) ASTFunctionCall(org.eclipse.rdf4j.query.parser.serql.ast.ASTFunctionCall) FunctionCall(org.eclipse.rdf4j.query.algebra.FunctionCall)

Example 2 with FunctionCall

use of org.eclipse.rdf4j.query.algebra.FunctionCall in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@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;
}
Also used : IRI(org.eclipse.rdf4j.model.IRI) ValueConstant(org.eclipse.rdf4j.query.algebra.ValueConstant) QueryModelNode(org.eclipse.rdf4j.query.algebra.QueryModelNode) IsBNode(org.eclipse.rdf4j.query.algebra.IsBNode) FunctionCall(org.eclipse.rdf4j.query.algebra.FunctionCall)

Example 3 with FunctionCall

use of org.eclipse.rdf4j.query.algebra.FunctionCall in project rdf4j by eclipse.

the class TupleExprBuilder method createFunctionCall.

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;
}
Also used : QueryModelNode(org.eclipse.rdf4j.query.algebra.QueryModelNode) IsBNode(org.eclipse.rdf4j.query.algebra.IsBNode) FunctionCall(org.eclipse.rdf4j.query.algebra.FunctionCall)

Aggregations

FunctionCall (org.eclipse.rdf4j.query.algebra.FunctionCall)3 IRI (org.eclipse.rdf4j.model.IRI)2 IsBNode (org.eclipse.rdf4j.query.algebra.IsBNode)2 QueryModelNode (org.eclipse.rdf4j.query.algebra.QueryModelNode)2 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)2 ASTFunctionCall (org.eclipse.rdf4j.query.parser.serql.ast.ASTFunctionCall)1 ASTValueExpr (org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr)1