public static void explain(String message, Op op, Context context) { if ( explaining(InfoLevel.FINE, logExec, context) ) { try (IndentedLineBuffer iBuff = new IndentedLineBuffer()) { if ( MultiLinesForOps ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; op.output(iBuff) ; String x = iBuff.asString() ; _explain(logExec, message, x, true) ; } } }
public static void explain(String message, Query query, Context context) { if ( explaining(InfoLevel.INFO, logExec, context) ) { // One line or indented multiline format IndentedLineBuffer iBuff = new IndentedLineBuffer() ; if ( true ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; query.serialize(iBuff) ; String x = iBuff.asString() ; _explain(logExec, message, x, true) ; } }
public static void explain(String message, QuadPattern quads, Context context) { if ( explaining(InfoLevel.ALL, logExec, context) ) { try (IndentedLineBuffer iBuff = new IndentedLineBuffer()) { if ( MultiLinesForPatterns ) iBuff.incIndent() ; formatQuads(iBuff, quads) ; iBuff.flush() ; String str = iBuff.toString() ; _explain(logExec, message, str, false) ; } } }
public static void explain(String message, Op op, Context context) { if ( explaining(InfoLevel.FINE, logExec, context) ) { IndentedLineBuffer iBuff = new IndentedLineBuffer() ; if ( true ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; op.output(iBuff) ; String x = iBuff.asString() ; _explain(logExec, message, x, true) ; } }
public static void explain(String message, Query query, Context context) { if ( explaining(InfoLevel.INFO, logExec, context) ) { // One line or indented multiline format IndentedLineBuffer iBuff = new IndentedLineBuffer() ; if ( true ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; query.serialize(iBuff) ; String x = iBuff.asString() ; _explain(logExec, message, x, true) ; } }
public static void explain(String message, BasicPattern bgp, Context context) { if ( explaining(InfoLevel.ALL, logExec, context) ) { try (IndentedLineBuffer iBuff = new IndentedLineBuffer()) { if ( MultiLinesForPatterns ) iBuff.incIndent() ; formatTriples(iBuff, bgp) ; iBuff.flush() ; String str = iBuff.toString() ; _explain(logExec, message, str, false) ; } } }
public static void explain(String message, QuadPattern quads, Context context) { if ( explaining(InfoLevel.ALL, logExec,context) ) { IndentedLineBuffer iBuff = new IndentedLineBuffer() ; if ( true ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; formatQuads(iBuff, quads) ; iBuff.flush() ; String str = iBuff.toString() ; _explain(logExec, message, str, false) ; } }
@Override public String toPrefixString() { IndentedLineBuffer x = new IndentedLineBuffer() ; x.append("(") ; x.append(getName().toLowerCase(Locale.ROOT)) ; x.incIndent(); if ( isDistinct ) x.append(" distinct") ; for ( Expr e : getExprList() ) { x.append(" "); WriterExpr.output(x, e, null) ; } x.decIndent(); x.append(")") ; return x.asString() ; }
@Override public String toPrefixString() { IndentedLineBuffer x = new IndentedLineBuffer(); x.append("("); x.append(getName().toLowerCase(Locale.ROOT)); x.append(" <"); x.append(iri); x.append("> "); x.incIndent(); if ( isDistinct ) x.append("distinct "); boolean first = true; for ( Expr e : getExprList() ) { if ( !first ) x.append(" "); first = false; WriterExpr.output(x, e, null); first = false; } x.decIndent(); x.append(")"); return x.asString(); }
@Test public void write02() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.incIndent() ; b.print("hell") ; b.print("o") ; b.decIndent() ; assertEquals(" hello", b.asString()) ; } }
protected static String prefixGroupConcatString(boolean isDistinct, String separator, ExprList exprs) { IndentedLineBuffer x = new IndentedLineBuffer() ; x.append("(") ; x.append("group_concat") ; if ( isDistinct ) x.append(" distinct") ; if ( separator != null ) { String y = StrUtils.escapeString(separator) ; x.append("(separator '") ; x.append(y) ; x.append("')") ; } x.incIndent(); for ( Expr e : exprs ) { x.append(" "); WriterExpr.output(x, e, null) ; } x.decIndent(); x.append(")") ; return x.asString() ; }
@Test public void write03() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.incIndent() ; b.printf("0x%04X", 1) ; b.println() ; b.print("XX") ; b.decIndent() ; assertEquals(" 0x0001\n XX", b.asString()) ; } }
@Override public String asSparqlExpr(SerializationContext sCxt) { IndentedLineBuffer x = new IndentedLineBuffer(); if ( !AggregateRegistry.isRegistered(iri) ) { // If not registered and if parsed in again not registered, it becomes a // function. // AGG <iri>(...) syntax. It can't have been legal SPARQL 1.1 unless it got // unregistered in which case all bets are off anyway. x.append(getName()); x.append(" "); } String uriStr = FmtUtils.stringForURI(iri, sCxt) ; x.append(uriStr) ; x.append("("); if ( isDistinct ) x.append("DISTINCT "); x.incIndent(); ExprUtils.fmtSPARQL(x, getExprList(), sCxt); x.decIndent(); x.append(")"); return x.asString(); }