Search in sources :

Example 16 with IndentedLineBuffer

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

the class AggregatorBase method toPrefixString.

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

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

the class AggGroupConcat method prefixGroupConcatString.

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();
}
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 18 with IndentedLineBuffer

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

the class TestIndentedWriter method write01.

@Test
public void write01() {
    try (IndentedLineBuffer b = new IndentedLineBuffer()) {
        b.print("hell");
        b.print("o");
        assertEquals("hello", b.asString());
    }
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) Test(org.junit.Test)

Example 19 with IndentedLineBuffer

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

the class TestIndentedWriter method write05.

@Test
public void write05() {
    try (IndentedLineBuffer b = new IndentedLineBuffer()) {
        b.setLineNumbers(true);
        b.println("ABCD");
        b.println("XYZ");
        assertEquals("  1 ABCD\n  2 XYZ\n", b.asString());
    }
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) Test(org.junit.Test)

Example 20 with IndentedLineBuffer

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

the class TestIndentedWriter method write06.

@Test
public void write06() {
    try (IndentedLineBuffer b = new IndentedLineBuffer()) {
        b.setLinePrefix("@.");
        b.println("ABCD");
        b.print("XYZ");
        assertEquals("@.ABCD\n@.XYZ", b.asString());
    }
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) Test(org.junit.Test)

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