Search in sources :

Example 46 with IndentedLineBuffer

use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.

the class AggGroupConcat method asSparqlExpr.

protected static String asSparqlExpr(boolean isDistinct, String separator, ExprList exprs, SerializationContext sCxt) {
    IndentedLineBuffer x = new IndentedLineBuffer();
    x.append("GROUP_CONCAT(");
    if (isDistinct)
        x.append("DISTINCT ");
    ExprUtils.fmtSPARQL(x, exprs, sCxt);
    if (separator != null) {
        x.append(" ; separator=");
        String y = StrUtils.escapeString(separator);
        x.append("'");
        x.append(y);
        x.append("'");
    }
    x.append(")");
    return x.asString();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 47 with IndentedLineBuffer

use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.

the class AggregatorBase method asSparqlExpr.

@Override
public String asSparqlExpr(SerializationContext sCxt) {
    IndentedLineBuffer x = new IndentedLineBuffer();
    x.append(getName());
    x.append("(");
    if (isDistinct)
        x.append("DISTINCT ");
    if (getExprList() != null)
        ExprUtils.fmtSPARQL(x, getExprList(), sCxt);
    x.append(")");
    return x.asString();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 48 with IndentedLineBuffer

use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.

the class TestSerialization method runTestWorker.

protected void runTestWorker(Query query, Syntax syntax) {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    query.serialize(buff, syntax);
    String baseURI = null;
    if (!query.explicitlySetBaseURI())
        // Not in query - use the same one (e.g. file read from) .  
        baseURI = query.getBaseURI();
    try {
        QueryUtils.checkParse(query);
    } catch (RuntimeException ex) {
        System.err.println("**** Test: " + getName());
        System.err.println("** " + ex.getMessage());
        System.err.println(query);
        throw ex;
    }
    try {
        QueryUtils.checkOp(query, true);
    } catch (SSEParseException ex) {
        System.err.println("**** Test: " + getName());
        System.err.println("** Algebra error: " + ex.getMessage());
    }
}
Also used : SSEParseException(org.apache.jena.sparql.sse.SSEParseException) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 49 with IndentedLineBuffer

use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.

the class QueryValidatorJSON method string.

private static String string(Query query, Op op) {
    final SerializationContext sCxt = new SerializationContext(query);
    IndentedLineBuffer out = new IndentedLineBuffer();
    op.output(out, sCxt);
    return out.asString();
}
Also used : SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 50 with IndentedLineBuffer

use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.

the class QueryValidatorJSON method formatted.

private static void formatted(JsonBuilder obj, Query query) {
    IndentedLineBuffer out = new IndentedLineBuffer();
    query.serialize(out);
    obj.key(jFormatted).value(out.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