@Override public NodeValue eval(List<NodeValue> args, FunctionEnv env) { // Instead of evalSpecial, we can rely on the machinery to evaluate the arguments to CALL first. // This precludes special forms for CALL first argument. // This code here is not usually called - evalSpecial is more general and is the main code path, NodeValue func = args.get(0) ; if (func == null) throw new ExprEvalException("CALL: Function identifier unbound"); if (func.isIRI()) { ExprList a = new ExprList() ; for ( int i = 1 ; i < args.size() ; i++ ) a.add(args.get(i)) ; //Expr e = null ; Expr e = new E_Function(func.getNode().getURI(), a); //Calling this may throw an error which we will just let bubble up return e.eval(null, env) ; } else throw new ExprEvalException("CALL: Function identifier not an IRI"); }
@Override public NodeValue eval(NodeValue x, NodeValue y) { if ( ! x.isString() ) throw new ExprEvalException("cast: arg 2 is not a string: "+x) ; if ( ! y.isIRI() ) throw new ExprEvalException("cast: arg 2 is not a URI: "+y) ; String lex = x.getString() ; y.asNode().getURI() ; throw new ARQNotImplemented() ; }
@Override public NodeValue eval(NodeValue x, NodeValue y) { if ( ! x.isString() ) throw new ExprEvalException("cast: arg 2 is not a string: "+x) ; if ( ! y.isIRI() ) throw new ExprEvalException("cast: arg 2 is not a URI: "+y) ; String lex = x.getString() ; y.asNode().getURI() ; throw new ARQNotImplemented() ; }
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) { if ( ! v1.isString() ) throw new ExprEvalException("Not a string (arg 1): "+v1) ; if ( ! v2.isIRI() ) throw new ExprEvalException("Not an IRI (arg 2): "+v2) ; String lex = v1.asString() ; Node dt = v2.asNode() ; // Check? Node n = Node.createLiteral(lex, null, Node.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) { if ( !v1.isString() ) throw new ExprEvalException("Not a string (arg 1): " + v1) ; if ( !v2.isIRI() ) throw new ExprEvalException("Not an IRI (arg 2): " + v2) ; String lex = v1.asString() ; Node dt = v2.asNode() ; // Check? Node n = NodeFactory.createLiteral(lex, null, NodeFactory.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { //No argument returns unbound if (identExpr == null) throw new ExprEvalException("CALL() has no arguments"); //One/More arguments means invoke a function dynamically NodeValue func = identExpr.eval(binding, env); if (func == null) throw new ExprEvalException("CALL: Function identifier unbound"); if (func.isIRI()) { Expr e = buildFunction(func.getNode().getURI(), argExprs, env.getContext()); if (e == null) throw new ExprEvalException("CALL: Function identifier <" + func.getNode().getURI() + "> does not identify a known function"); //Calling this may throw an error which we will just let bubble up return e.eval(binding, env); } else { throw new ExprEvalException("CALL: Function identifier not an IRI"); } }