@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; }
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 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; }
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; }
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 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; }
@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; }
@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; }
expr = new FunctionCall(funcName, args);
@Test public void periodicNodeNotPresentTest() throws Exception { List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(VF.createLiteral(12.0)), new ValueConstant(VF.createLiteral(6.0)), new ValueConstant(VF.createIRI(PeriodicQueryUtil.temporalNameSpace + "hours"))); FunctionCall func = new FunctionCall("uri:func", values); Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join()); Assert.assertEquals(false, node1.isPresent()); }
@Test public void periodicNodeFractionalDurationTest() throws Exception { List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(VF.createLiteral(1)), new ValueConstant(VF.createLiteral(.5)), new ValueConstant(VF.createIRI(PeriodicQueryUtil.temporalNameSpace + "hours"))); FunctionCall func = new FunctionCall(PeriodicQueryUtil.PeriodicQueryURI, values); Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join()); Assert.assertEquals(true, node1.isPresent()); double window = 1*60*60*1000; double period = .5*3600*1000; PeriodicQueryNode node2 = new PeriodicQueryNode((long) window, (long) period, TimeUnit.MILLISECONDS, "time", new Join()); Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node1.get(), node2)); }
@Test public void periodicNodePresentTest() throws Exception { List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(VF.createLiteral(12.0)), new ValueConstant(VF.createLiteral(6.0)), new ValueConstant(VF.createIRI(PeriodicQueryUtil.temporalNameSpace + "hours"))); FunctionCall func = new FunctionCall(PeriodicQueryUtil.PeriodicQueryURI, values); Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join()); Assert.assertEquals(true, node1.isPresent()); PeriodicQueryNode node2 = new PeriodicQueryNode(12*60*60*1000L, 6*3600*1000L, TimeUnit.MILLISECONDS, "time", new Join()); Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node1.get(), node2)); }