Search in sources :

Example 41 with IndentedLineBuffer

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();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 42 with IndentedLineBuffer

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());
}
Also used : BasicPattern(org.apache.jena.sparql.core.BasicPattern) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) Test(org.junit.Test)

Example 43 with IndentedLineBuffer

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());
}
Also used : BasicPattern(org.apache.jena.sparql.core.BasicPattern) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) Test(org.junit.Test)

Example 44 with IndentedLineBuffer

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();
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) WriterExpr(org.apache.jena.sparql.sse.writers.WriterExpr) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 45 with IndentedLineBuffer

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();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Aggregations

IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)63 Test (org.junit.Test)10 SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)5 Expr (org.apache.jena.sparql.expr.Expr)3 WriterExpr (org.apache.jena.sparql.sse.writers.WriterExpr)3 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 QueryCheckException (org.apache.jena.sparql.core.QueryCheckException)2 SSEParseException (org.apache.jena.sparql.sse.SSEParseException)2 UpdateRequest (org.apache.jena.update.UpdateRequest)2 Version (org.apache.jena.atlas.lib.Version)1 DatasetRef (org.apache.jena.fuseki.server.DatasetRef)1 Node (org.apache.jena.graph.Node)1 Triple (org.apache.jena.graph.Triple)1 Query (org.apache.jena.query.Query)1 QueryException (org.apache.jena.query.QueryException)1 QueryParseException (org.apache.jena.query.QueryParseException)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1 PrefixMapping (org.apache.jena.shared.PrefixMapping)1 Op (org.apache.jena.sparql.algebra.Op)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1