Search in sources :

Example 31 with IndentedLineBuffer

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

the class ExprUtils method fmtSPARQL.

public static String fmtSPARQL(Expr expr) {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    fmtSPARQL(buff, expr);
    return buff.toString();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 32 with IndentedLineBuffer

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

the class uparse method execOne.

private void execOne(String updateString, Syntax syntax) {
    UpdateRequest req;
    try {
        req = UpdateFactory.create(updateString, syntax);
    } catch (QueryParseException ex) {
        System.err.print("Parse error: ");
        System.err.println(ex.getMessage());
        return;
    }
    //req.output(IndentedWriter.stderr) ;
    if (printUpdate)
        System.out.print(req);
    if (printNone)
        return;
    // And some checking.
    IndentedLineBuffer w = new IndentedLineBuffer();
    UpdateWriter.output(req, w);
    String updateString2 = w.asString();
    UpdateRequest req2 = null;
    try {
        req2 = UpdateFactory.create(updateString2, syntax);
    } catch (QueryParseException ex) {
        System.err.println("Can not reparse update after serialization");
        System.err.println(updateString2);
    }
    if (!req.equalTo(req2))
        System.err.println("Reparsed update does not .equalTo original parsed request");
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) QueryParseException(org.apache.jena.query.QueryParseException) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 33 with IndentedLineBuffer

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

the class MgtFunctions method prefixes.

/** Return prefixes for the datasets, SPARQL syntax. */
public static String prefixes(HttpServletRequest request) {
    String dsName = dataset(request);
    DatasetRef desc = getFromRegistry(dsName);
    if (desc == null)
        return "<not found>";
    DatasetGraph dsg = desc.dataset;
    if (dsg instanceof DatasetGraphTDB) {
        PrefixMapping pmap = ((DatasetGraphTDB) dsg).getPrefixes().getPrefixMapping();
        Prologue prologue = new Prologue(pmap);
        IndentedLineBuffer buff = new IndentedLineBuffer();
        PrologueSerializer.output(buff, prologue);
        buff.append("\n");
        return buff.asString();
    }
    return "";
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Prologue(org.apache.jena.sparql.core.Prologue) DatasetRef(org.apache.jena.fuseki.server.DatasetRef) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 34 with IndentedLineBuffer

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

the class SqlExprBase method asSQL.

public static String asSQL(SqlExpr expr) {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    SqlExprVisitor v = new SqlExprGenerateSQL(buff);
    expr.visit(v);
    return buff.toString();
}
Also used : IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer)

Example 35 with IndentedLineBuffer

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

the class TableFinder method toString.

@Override
public String toString() {
    IndentedLineBuffer buff = new IndentedLineBuffer();
    output(buff, true);
    return buff.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