@Override public boolean equals(Object other) { if (other instanceof FunctionCall) { FunctionCall o = (FunctionCall)other; return uri.equals(o.getURI()) && args.equals(o.getArgs()); } return false; }
/** * Returns a PeriodicQueryNode for all {@link FunctionCall}s that represent PeriodicQueryNodes, otherwise * an empty Optional is returned. * @param functionCall - FunctionCall taken from a {@lin TupleExpr} * @param arg - TupleExpr that will be the argument of the PeriodicQueryNode if it is created * @return - Optional containing a PeriodicQueryNode if FunctionCall represents PeriodicQueryNode and empty Optional otherwise * @throws Exception */ public static Optional<PeriodicQueryNode> getPeriodicQueryNode(FunctionCall functionCall, TupleExpr arg) throws Exception { if (functionCall.getURI().equals(PeriodicQueryURI)) { return Optional.of(parseAndSetValues(functionCall.getArgs(), arg)); } return Optional.empty(); }
private Value[] extractArguments(final String matchName, final FunctionCall call) { final Value args[] = new Value[call.getArgs().size() - 1]; int argI = 0; for (int i = 0; i != call.getArgs().size(); ++i) { final ValueExpr arg = call.getArgs().get(i); if (argI == i && arg instanceof Var && matchName.equals(((Var)arg).getName())) { continue; } if (arg instanceof ValueConstant) { args[argI] = ((ValueConstant)arg).getValue(); } else if (arg instanceof Var && ((Var)arg).hasValue()) { args[argI] = ((Var)arg).getValue(); } else { throw new IllegalArgumentException("Query error: Found " + arg + ", expected a Literal, BNode or URI"); } ++argI; } return args; }
/** * @inheritDoc */ @Override public void meet(FunctionCall theOp) throws Exception { mBuffer.append(theOp.getURI()).append("("); boolean aFirst = true; for (ValueExpr aArg : theOp.getArgs()) { if (!aFirst) { mBuffer.append(", "); } else { aFirst = false; } aArg.visit(this); } mBuffer.append(")"); }
@Override public void meet(final FunctionCall fn) { final URI fun = new URIImpl(fn.getURI()); final Var result = IndexingFunctionRegistry.getResultVarFromFunctionCall(fun, fn.getArgs()); if (result != null && !searchProperties.contains(result)) { searchProperties.add(result); } } }
/** * @inheritDoc */ @Override public void meet(FunctionCall theOp) throws Exception { mBuffer.append("<").append(theOp.getURI()).append(">("); boolean aFirst = true; for (ValueExpr aArg : theOp.getArgs()) { if (!aFirst) { mBuffer.append(", "); } else { aFirst = false; } aArg.visit(this); } mBuffer.append(")"); }
@Override public void meet(FunctionCall node) throws RuntimeException { NativeFunction nf = NativeFunctionRegistry.getInstance().get(node.getURI()); if(node.getArgs().size() > 0 && nf.getReturnType() == ValueType.STRING) { node.getArgs().get(0).visit(this); } // otherwise stop here, the function call hides the type and language anyways }
@Override public void meet(final FunctionCall n) { final String uri = n.getURI(); String name = NAMES.get(uri); if (name == null && NAMES.values().contains(uri.toUpperCase())) { name = n.getURI().toUpperCase(); } emit(name != null ? name : new URIImpl(uri)).emit("(").emit(n.getArgs(), ", ") .emit(")"); }
@Override public void meet(final FunctionCall n) { final String uri = n.getURI(); String name = NAMES.get(uri); if (name == null && NAMES.values().contains(uri.toUpperCase())) { name = n.getURI().toUpperCase(); } emit(name != null ? name : new URIImpl(uri)).emit("(").emit(n.getArgs(), ", ") .emit(")"); }
@Override public void meet(FunctionCall fc) throws RuntimeException { if((XMLSchema.DOUBLE.toString().equals(fc.getURI()) || XMLSchema.FLOAT.toString().equals(fc.getURI()) ) && fc.getArgs().size() == 1) { optypes.push(ValueType.DOUBLE); fc.getArgs().get(0).visit(this); optypes.pop(); } else if((XMLSchema.INTEGER.toString().equals(fc.getURI()) || XMLSchema.INT.toString().equals(fc.getURI())) && fc.getArgs().size() == 1) { optypes.push(ValueType.INT); fc.getArgs().get(0).visit(this); optypes.pop(); } else if(XMLSchema.BOOLEAN.toString().equals(fc.getURI()) && fc.getArgs().size() == 1) { optypes.push(ValueType.BOOL); fc.getArgs().get(0).visit(this); optypes.pop(); } else if(XMLSchema.DATE.toString().equals(fc.getURI()) && fc.getArgs().size() == 1) { optypes.push(ValueType.DATE); fc.getArgs().get(0).visit(this); optypes.pop(); } else { String[] args = new String[fc.getArgs().size()]; args[i] = new ValueExpressionEvaluator(fc.getArgs().get(i), parent, nf.getArgumentType(i)).build();
@Override public void meet(FunctionCall node) throws RDFHandlerException { Resource currentSubj = subject; flushPendingStatement(); handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, toValue(node))); List<ValueExpr> args = node.getArgs(); for (int i = 0; i < args.size(); i++) { predicate = toArgProperty(i + 1); args.get(i).visit(this); } subject = currentSubj; predicate = null; }
@Override public void meet(final Filter node) throws Exception { super.meet(node); final ValueExpr arg = node.getCondition(); if (arg instanceof FunctionCall) { final FunctionCall fc = (FunctionCall) arg; if (RANGE.stringValue().equals(fc.getURI())) { //range(?var, start, end) final List<ValueExpr> valueExprs = fc.getArgs(); if (valueExprs.size() != 3) { throw new QueryEvaluationException("org.apache:range must have 3 parameters: variable, start, end"); } final Var var = (Var) valueExprs.get(0); final ValueConstant startVc = (ValueConstant) valueExprs.get(1); final ValueConstant endVc = (ValueConstant) valueExprs.get(2); final Value start = startVc.getValue(); final Value end = endVc.getValue(); rangeValues.put(var, new RangeValue(start, end)); node.setCondition(new ValueConstant(BooleanLiteralImpl.TRUE)); } } }
@Override public void meet(FunctionCall node) { handleType(SeRQO.FUNCTIONCALL); handleLiteral(SeRQO.URI, node.getURI()); handleChildList(SeRQO.ARGS, node.getArgs()); super.meet(node); }
/** * Evaluates a function. */ public Value evaluate(FunctionCall node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Function function = FunctionRegistry.getInstance().get(node.getURI()).orElseThrow( () -> new QueryEvaluationException("Unknown function '" + node.getURI() + "'")); // the NOW function is a special case as it needs to keep a shared // return // value for the duration of the query. if (function instanceof Now) { return evaluate((Now)function, bindings); } List<ValueExpr> args = node.getArgs(); Value[] argValues = new Value[args.size()]; for (int i = 0; i < args.size(); i++) { argValues[i] = evaluate(args.get(i), bindings); } return function.evaluate(tripleSource.getValueFactory(), argValues); }
super.meet(functionCall); List<ValueExpr> args = functionCall.getArgs();
@Override public void meet(FunctionCall f) throws SailException { if(f.getURI().startsWith(GEOF.NAMESPACE)) { List<ValueExpr> args = f.getArgs(); if(args.size() != 2) { return;
@Override public void meet(final FunctionCall call) { final URI fnUri = valueFactory.createURI(call.getURI()); final Var resultVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(fnUri, call.getArgs()); if (resultVar != null && resultVar.getName().equals(matchVar)) { addFilter(valueFactory.createURI(call.getURI()), extractArguments(matchVar, call)); if (call.getParentNode() instanceof Filter || call.getParentNode() instanceof And || call.getParentNode() instanceof LeftJoin) { call.replaceWith(new ValueConstant(valueFactory.createLiteral(true))); } else { throw new IllegalArgumentException("Query error: Found " + call + " as part of an expression that is too complex"); } } }
@Override public void meet(FunctionCall f) throws SailException { if(GEOF.DISTANCE.stringValue().equals(f.getURI())) { List<ValueExpr> args = f.getArgs(); if(args.size() != 3) { return;