@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()) ; } }
@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()) ; } }
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() ; }
@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(); }