/** * Handle a simple unary function (the child of the node is the argument to * the function). */ protected FunctionNode unary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node) }); }
/** * Handle a simple unary function (the child of the node is the argument to * the function). */ protected FunctionNode unary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node) }); }
/** * Handle a simple binary function (both children of the node are arguments * to the function). */ protected FunctionNode binary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node) }); }
/** * Handle a simple binary function (both children of the node are arguments * to the function). */ protected FunctionNode binary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node) }); }
@Override final public FunctionNode visit(ASTIRIFunc node, Object data) throws VisitorException { return new FunctionNode(FunctionRegistry.IRI, // null/* scalarValues */, Collections.singletonMap(IriBOp.Annotations.BASE_URI, (Object) node.getBaseURI()), new ValueExpressionNode[] { left(node) }); // return unary(node, FunctionRegistry.IRI); /* * FIXME baseURI resolution needs to be handled for IRI functions, most * likely in unary(), binary(), nary(), and aggregate(). Write AST * layer unit tests for this. */ // ValueExpr expr = (ValueExpr)node.jjtGetChild(0).jjtAccept(this, null); // IRIFunction fn = new IRIFunction(expr); // fn.setBaseURI(node.getBaseURI()); // return fn; }
@Override final public FunctionNode visit(ASTIRIFunc node, Object data) throws VisitorException { return new FunctionNode(FunctionRegistry.IRI, // null/* scalarValues */, Collections.singletonMap(IriBOp.Annotations.BASE_URI, (Object) node.getBaseURI()), new ValueExpressionNode[] { left(node) }); // return unary(node, FunctionRegistry.IRI); /* * FIXME baseURI resolution needs to be handled for IRI functions, most * likely in unary(), binary(), nary(), and aggregate(). Write AST * layer unit tests for this. */ // ValueExpr expr = (ValueExpr)node.jjtGetChild(0).jjtAccept(this, null); // IRIFunction fn = new IRIFunction(expr); // fn.setBaseURI(node.getBaseURI()); // return fn; }
/** * Handle a simple ternary function (there are three children of the node * which are the arguments to the function). */ protected FunctionNode ternary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node), (ValueExpressionNode) node.jjtGetChild(2).jjtAccept( this, null) }); }
/** * Handle a simple ternary function (there are three children of the node * which are the arguments to the function). */ protected FunctionNode ternary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node), (ValueExpressionNode) node.jjtGetChild(2).jjtAccept( this, null) }); }
/** * TODO additional scalar values (sparql.jjt specifies "separator EQ" as a * constant in the grammar, but we support additional scalar values for * {@link GROUP_CONCAT}. Also, the grammar is permissive and allows * Expression for separator rather than a quoted string (per the W3C draft). */ @Override final public FunctionNode visit(ASTGroupConcat node, Object data) throws VisitorException { Map<String, Object> scalarValues = new LinkedHashMap<String, Object>(); if (node.isDistinct()) { scalarValues.put(AggregateBase.Annotations.DISTINCT, Boolean.TRUE); } if (node.jjtGetNumChildren() > 1) { final ConstantNode separator = (ConstantNode) node.jjtGetChild(1) .jjtAccept(this, data); scalarValues.put(GROUP_CONCAT.Annotations.SEPARATOR, separator .getValue().stringValue()); } return new FunctionNode(FunctionRegistry.GROUP_CONCAT, scalarValues, new ValueExpressionNode[] { left(node) }); }
/** * TODO additional scalar values (sparql.jjt specifies "separator EQ" as a * constant in the grammar, but we support additional scalar values for * {@link GROUP_CONCAT}. Also, the grammar is permissive and allows * Expression for separator rather than a quoted string (per the W3C draft). */ @Override final public FunctionNode visit(ASTGroupConcat node, Object data) throws VisitorException { Map<String, Object> scalarValues = new LinkedHashMap<String, Object>(); if (node.isDistinct()) { scalarValues.put(AggregateBase.Annotations.DISTINCT, Boolean.TRUE); } if (node.jjtGetNumChildren() > 1) { final ConstantNode separator = (ConstantNode) node.jjtGetChild(1) .jjtAccept(this, data); scalarValues.put(GROUP_CONCAT.Annotations.SEPARATOR, separator .getValue().stringValue()); } return new FunctionNode(FunctionRegistry.GROUP_CONCAT, scalarValues, new ValueExpressionNode[] { left(node) }); }
protected FunctionNode aggregate(final ASTAggregate node, final URI functionURI) throws VisitorException { Map<String, Object> scalarValues = null; if (node.isDistinct()) { scalarValues = Collections.singletonMap( AggregateBase.Annotations.DISTINCT, (Object) Boolean.TRUE); } if (node instanceof ASTCount && ((ASTCount) node).isWildcard()) { /* * Note: The wildcard is dropped by openrdf. */ return new FunctionNode(functionURI, scalarValues, new ValueExpressionNode[] { new VarNode("*") }); } return new FunctionNode(functionURI, scalarValues, new ValueExpressionNode[] { left(node) }); }
protected FunctionNode aggregate(final ASTAggregate node, final URI functionURI) throws VisitorException { Map<String, Object> scalarValues = null; if (node.isDistinct()) { scalarValues = Collections.singletonMap( AggregateBase.Annotations.DISTINCT, (Object) Boolean.TRUE); } if (node instanceof ASTCount && ((ASTCount) node).isWildcard()) { /* * Note: The wildcard is dropped by openrdf. */ return new FunctionNode(functionURI, scalarValues, new ValueExpressionNode[] { new VarNode("*") }); } return new FunctionNode(functionURI, scalarValues, new ValueExpressionNode[] { left(node) }); }
/** * Handle a function with four arguments (there are four children of the * node which are the arguments to the function). */ protected FunctionNode quadary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node), (ValueExpressionNode) node.jjtGetChild(2).jjtAccept( this, null), (ValueExpressionNode) node.jjtGetChild(3).jjtAccept( this, null)}); }
/** * Handle a function with four arguments (there are four children of the * node which are the arguments to the function). */ protected FunctionNode quadary(final SimpleNode node, final URI functionURI) throws VisitorException { return new FunctionNode(functionURI, null/* scalarValues */, new ValueExpressionNode[] { left(node), right(node), (ValueExpressionNode) node.jjtGetChild(2).jjtAccept( this, null), (ValueExpressionNode) node.jjtGetChild(3).jjtAccept( this, null)}); }