@Override public NodeValue eval(NodeValue v) { return NodeFunctions.str(v) ; }
public String asString() { // Do not call .toString() forceToNode() ; return NodeFunctions.str(node) ; }
@Override public NodeValue exec(NodeValue nodeValue) { nodeValue = NodeFunctions.str(nodeValue) ; return sha1.eval(nodeValue) ; } }
@Override public NodeValue exec(NodeValue v1, NodeValue v2) { // retrieve collation value String collation = NodeFunctions.str(v1.asNode()); // return a NodeValue that contains the v2 literal string, plus the given collation return NodeFunctions.sortKey(v2, collation); }
public static NodeValue sortKey(NodeValue nv, String collation) { return NodeValue.makeSortKey(str(nv.asNode()), collation) ; }
public static NodeValue str(NodeValue nv) { return NodeValue.makeString(str(nv.asNode())) ; }
@Override public NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("FunctionBase1: Null args list") ; switch(args.size()) { case 0: throw new ExprEvalException(); case 1: { NodeValue nv = args.get(0); String str = NodeFunctions.str(nv.asNode()); throw new ExprEvalException(str); } default: throw new ExprEvalException("fn:error: Wrong number of arguments: Wanted 0 or 1, got "+args.size()) ; } } }
@Test(expected=ExprTypeException.class) public void testStr4() { Node n = NodeFactory.createBlankNode() ; String s = NodeFunctions.str(n) ; }
objVals.add(NodeFunctions.str(nvValue)); break;
@Test public void testStr3() { NodeValue nv = NodeValue.makeNode("abc", "fr", (String)null) ; NodeValue s = NodeFunctions.str(nv) ; assertEquals("abc", s.getString()) ; }
@Test public void testStr2() { NodeValue nv = NodeValue.makeInteger(56) ; NodeValue s = NodeFunctions.str(nv) ; assertEquals("56", s.getString()) ; }
@Test public void testStr1() { NodeValue nv = NodeValue.makeNodeInteger(56) ; NodeValue s = NodeFunctions.str(nv) ; assertEquals("56", s.getString()) ; }
@Override public QueryIterator execEvaluated(Binding binding, Node subject, Node predicate, PropFuncArg object, ExecutionContext execCxt) { if ( ! Var.isVar(subject) ) throw new ExprEvalException("Subject is not a variable ("+subject+")") ; String x = "" ; for ( Node node : object.getArgList() ) { if ( Var.isVar(node) ) return IterLib.noResults(execCxt) ; String str = NodeFunctions.str(node) ; x = x+str ; } return IterLib.oneResult(binding, Var.alloc(subject), NodeFactory.createLiteral(x), execCxt) ; }
private ResultSetRewindable convertToStrings(ResultSetRewindable resultsActual) { List<Binding> bindings = new ArrayList<>() ; while(resultsActual.hasNext()) { Binding b = resultsActual.nextBinding() ; BindingMap b2 = BindingFactory.create() ; for ( String vn : resultsActual.getResultVars() ) { Var v = Var.alloc(vn) ; Node n = b.get(v) ; String s ; if ( n == null ) s = "" ; else if ( n.isBlank() ) s = "_:"+n.getBlankNodeLabel() ; else s = NodeFunctions.str(n) ; b2.add(v, NodeFactory.createLiteral(s)) ; } bindings.add(b2) ; } ResultSet rs = new ResultSetStream(resultsActual.getResultVars(), null, new QueryIterPlainWrapper(bindings.iterator())) ; return ResultSetFactory.makeRewindable(rs) ; }
throw new QueryExecException("str: object is a blank node") ; Node strValue = NodeFactory.createLiteral(NodeFunctions.str(object)) ;