use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class SSE method string.
// public static String str(ResultSet rs) {
// return str(rs, getPrefixMapString()) ;
// }
//
// public static String str(ResultSet rs, PrefixMapping pmap) {
// return string((out)->Writer???.output(out, rs, sCxt(pmap))) ;
// }
private static String string(Consumer<IndentedLineBuffer> action) {
IndentedLineBuffer x = new IndentedLineBuffer();
action.accept(x);
return x.asString();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class TestFmtUtils method testFormatBGP_1.
@Test
public void testFormatBGP_1() {
IndentedLineBuffer b = new IndentedLineBuffer();
BasicPattern bgp = SSE.parseBGP("(prefix ((zz: <" + aUri + ">)) (bgp (zz:s zz:p zz:o)))");
FmtUtils.formatPattern(b, bgp, getContext());
assertEquals("zz:s zz:p zz:o .", b.toString());
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class TestFmtUtils method testFormatBGP_2.
@Test
public void testFormatBGP_2() {
IndentedLineBuffer b = new IndentedLineBuffer();
BasicPattern bgp = SSE.parseBGP("(prefix ((zz: <" + aUri + ">)) (bgp (zz:s zz:p zz:o) (zz:s zz:p 123) ))");
FmtUtils.formatPattern(b, bgp, getContext());
assertEquals("zz:s zz:p zz:o .\nzz:s zz:p 123 .", b.toString());
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class AggCustom method toPrefixString.
@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();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class AggCustom method asSparqlExpr.
@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();
}
Aggregations