public boolean isURI() { return nv.isIRI(); } public boolean isBlank() { return nv.isBlank(); }
if(nv.isString()) { url = nv.getString(); } else if(nv.isIRI()) { Node node = nv.asNode(); url = node.getURI();
if(nv.isString()) { url = nv.getString(); } else if(nv.isIRI()) { Node node = nv.asNode(); url = node.getURI();
@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"); }
NodeValue result = NodeValue.FALSE; try { if(nv.isIRI()) { Node node = nv.asNode(); String iri = node.getURI();
NodeValue result = NodeValue.FALSE; try { if(nv.isIRI()) { Node node = nv.asNode(); String iri = node.getURI();
if(nv.isString()) { url = nv.getString(); } else if(nv.isIRI()) { Node node = nv.asNode(); url = node.getURI();
if(nv.isString()) { url = nv.getString(); } else if(nv.isIRI()) { Node node = nv.asNode(); url = node.getURI();
@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 determineLang(NodeValue nv) { NodeValue result = null;//NodeValue.nvNothing;// Expr.NONE.getConstant(); if(nv.isIRI()) { String iri = nv.asNode().getURI(); Lang lang = RDFDataMgr.determineLang(iri, null, null); if(lang != null) { result = NodeValue.makeString(lang.getContentType().getContentType()); } } if(result == null) { throw new ExprEvalException("no result for determineLang with arg " + nv); } return result; } }
public static NodeValue determineLang(NodeValue nv) { NodeValue result = null;//NodeValue.nvNothing;// Expr.NONE.getConstant(); if(nv.isIRI()) { String iri = nv.asNode().getURI(); Lang lang = RDFDataMgr.determineLang(iri, null, null); if(lang != null) { result = NodeValue.makeString(lang.getContentType().getContentType()); } } if(result == null) { throw new ExprEvalException("no result for determineLang with arg " + nv); } return result; } }
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, NodeFactory.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
public static Object getValue(NodeValue expr) { if(expr == null) { return NodeValue.nvNothing; } else if(expr.isIRI()){
private static void testURI(String string, String uri) { Expr expr = parse(string) ; NodeValue v = expr.eval( env, new FunctionEnvBase()) ; assertTrue(v.isIRI()) ; assertEquals(uri, v.getNode().getURI()) ; }
@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"); } }
return null; if ( constant.isIRI() || constant.isBlank() ) return Pair.create(var, constant);