@Override final public FunctionNode visit(ASTCount node, Object data) throws VisitorException { return aggregate(node, FunctionRegistry.COUNT); }
@Override final public FunctionNode visit(ASTLangMatches node, Object data) throws VisitorException { return binary(node, FunctionRegistry.LANG_MATCHES); }
@Override final public FunctionNode visit(ASTSubstr node, Object data) throws VisitorException { return nary(node, FN.SUBSTRING); }
@Override final public FunctionNode visit(ASTFloor node, Object data) throws VisitorException { return unary(node, FN.NUMERIC_FLOOR); }
/** * 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(ASTRand node, Object data) throws VisitorException { return noneary(node, FunctionRegistry.RAND); }
/** * 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) }); }
@Override final public FunctionNode visit(ASTCompare node, Object data) throws VisitorException { final URI functionURI; switch (node.getOperator()) { case LT: functionURI = FunctionRegistry.LT; break; case GT: functionURI = FunctionRegistry.GT; break; case EQ: functionURI = FunctionRegistry.EQ; break; case LE: functionURI = FunctionRegistry.LE; break; case GE: functionURI = FunctionRegistry.GE; break; case NE: functionURI = FunctionRegistry.NE; break; default: throw new UnsupportedOperationException(node.getOperator() .getSymbol()); } return binary(node, functionURI); }
/** * See EXISTS above. * * @see NotExistsNode */ @Override final public NotExistsNode visit(final ASTNotExistsFunc node, Object data) throws VisitorException { final VarNode anonvar = context.createAnonVar("-exists-"); /* * Use a new (empty) graph pattern to prevent the accept of the child * from being attached into the parent's graph pattern context. */ final GroupGraphPattern parentGP = graphPattern; graphPattern = scopedGroupGraphPattern(node); @SuppressWarnings("unchecked") final GraphPatternGroup<IGroupMemberNode> innerGraphPattern = (GraphPatternGroup<IGroupMemberNode>) node .jjtGetChild(0).jjtAccept(this/* visitor */, null); final NotExistsNode fn = new NotExistsNode(anonvar, innerGraphPattern); // Restore the parent's context. graphPattern = parentGP; return fn; }
@Override final public FunctionNode visit(ASTIf node, Object data) throws VisitorException { return ternary(node, FunctionRegistry.IF); }
@Override final public FunctionNode visit(ASTRound node, Object data) throws VisitorException { return unary(node, FN.NUMERIC_ROUND); }
/** * 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 public FunctionNode visit(ASTSTRUUID node, Object data) throws VisitorException { return noneary(node, FunctionRegistry.STRUUID); }
/** * 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) }); }