public static String stringForNode(Node n) { StringBuilder sb = new StringBuilder(); stringForNode(sb, n, ARQConstants.getGlobalPrefixMap()) ; return sb.toString(); }
protected void output(Node node) { String $ = FmtUtils.stringForNode(node, sCxt) ; out.print($) ; }
private static void writeGraph(IndentedWriter out, Graph g, Node node, SerializationContext naming) { String x = null ; if ( node != null ) x = FmtUtils.stringForNode(node) ; _writeGraph(out, g, x, naming) ; }
@Override public String toString() { if ( getNode() != null ) { // Can be a plain string or an xsd:string. return FmtUtils.stringForNode(getNode()) ; } return '"'+string+'"' ; }
@Override public String toString() { if ( getNode() != null ) return FmtUtils.stringForNode(getNode()) ; return "'"+getString()+"'@"+lang ; }
@Override public String encode(Node node) { if ( node.isBlank() ) return "_:"+node.getBlankNodeId().getLabelString() ; String s = FmtUtils.stringForNode(node, prefixMapping) ; return s ; }
public static String lang(Node node) { if ( !node.isLiteral() ) NodeValue.raise(new ExprTypeException("lang: Not a literal: " + FmtUtils.stringForNode(node))) ; String s = node.getLiteralLanguage() ; if ( s == null ) s = "" ; return s ; }
public static boolean containsGraph(Store store, Node graphNode) { String qs = "SELECT * { GRAPH "+FmtUtils.stringForNode(graphNode)+" { ?s ?p ?o }} LIMIT 1" ; Dataset ds = SDBFactory.connectDataset(store) ; try ( QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ) { ResultSet rs = qExec.execSelect() ; return rs.hasNext() ; } }
public final String asQuotedString(SerializationContext context) { // If possible, make a node and use that as the formatted output. if ( node == null ) node = asNode() ; if ( node != null ) return FmtUtils.stringForNode(node, context) ; return toString() ; }
@Override protected void details(IndentedWriter out, SerializationContext cxt) { out.print(Lib.className(this)) ; out.print(" ?"+var.toString()+" = "+FmtUtils.stringForNode(node, cxt)) ; } }
@Override public NodeValue exec(NodeValue v) { Node n = v.asNode() ; if ( ! n.isURI() ) throw new ExprEvalException("Not a URI: "+FmtUtils.stringForNode(n)) ; String str = n.getLocalName() ; return NodeValue.makeString(str) ; } }
protected void checkQuad(Node graph, Node subject, Node predicate, Node object, long line, long col) { // Allow blank nodes - syntax may restrict more. if ( graph != null && !graph.isURI() && !graph.isBlank() ) { errorHandler.error("Graph name is not a URI or blank node: " + FmtUtils.stringForNode(graph), line, col); throw new RiotException("Bad graph name: " + graph); } checkTriple(subject, predicate, object, line, col); }
@Override public void output(IndentedWriter out, SerializationContext sCxt) { out.print("Procedure ["+FmtUtils.stringForNode(procId, sCxt)+"]") ; out.print("[") ; out.print(args.toString()) ; out.print("]") ; out.println() ; }
@Override protected void constantSlot(SDBRequest request, Node node, SqlColumn thisCol, SqlExprList conditions) { String str = codec.encode(node) ; SqlExpr c = new S_Equal(thisCol, new SqlConstant(str)) ; c.addNote("Const: "+FmtUtils.stringForNode(node)) ; conditions.add(c) ; return ; } }
@Test public void anonNode2() { FmtUtils.resetBNodeLabels(); assertEquals("_:b0", FmtUtils.stringForNode(NodeFactory.createBlankNode())) ; assertEquals("_:b1", FmtUtils.stringForNode(NodeFactory.createBlankNode())) ; assertEquals("_:b2", FmtUtils.stringForNode(NodeFactory.createBlankNode())) ; }
@Override protected void constantSlot(SDBRequest request, Node node, SqlColumn thisCol, SqlExprList conditions) { long hash = NodeLayout2.hash(node) ; SqlExpr c = new S_Equal(thisCol, new SqlConstant(hash)) ; String x = FmtUtils.stringForNode(node, request.getPrefixMapping()) ; c.addNote("Const: "+x) ; conditions.add(c) ; return ; } }
@Override protected void details(IndentedWriter out, SerializationContext sCxt) { out.print("PropertyFunction ["+FmtUtils.stringForNode(predicate, sCxt)+"]") ; out.print("[") ; argSubject.output(out, sCxt) ; out.print("][") ; argObject.output(out, sCxt) ; out.print("]") ; out.println() ; } }
@Override public void visit(OpService opService) { start(opService, NoNL) ; if ( opService.getSilent() ) out.println("silent ") ; out.println(FmtUtils.stringForNode(opService.getService(), sContext)) ; opService.getSubOp().visit(this) ; finish(opService) ; }
@Test public void anonNode1() { FmtUtils.resetBNodeLabels(); assertEquals("_:b0", FmtUtils.stringForNode(NodeFactory.createBlankNode())) ; }
@Override public void visit(OpPropFunc opPropFunc) { start(opPropFunc, NoNL) ; out.print(FmtUtils.stringForNode(opPropFunc.getProperty(), sContext)) ; out.println() ; outputPF(opPropFunc.getSubjectArgs()) ; out.print(" ") ; outputPF(opPropFunc.getObjectArgs()) ; out.println() ; printOp(opPropFunc.getSubOp()) ; finish(opPropFunc) ; }