Search in sources :

Example 21 with SerializationContext

use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.

the class Explain method formatQuads.

// public static void explainHTTP(String message, String request, Context
// context)
// {
// if ( explaining(InfoLevel.ALL, logExec,context) )
// {
// IndentedLineBuffer iBuff = new IndentedLineBuffer() ;
// if ( true )
// iBuff.incIndent() ;
// else
// iBuff.setFlatMode(true) ;
// ???
// iBuff.flush() ;
// String str = iBuff.toString() ;
// _explain(logExec, message, str, false) ;
// }
// }
// TEMP : quad list that looks right.
// Remove when QuadPatterns roll through from ARQ.
private static void formatQuads(IndentedLineBuffer out, QuadPattern quads) {
    SerializationContext sCxt = SSE.sCxt(SSE.getPrefixMapWrite());
    boolean first = true;
    for (Quad qp : quads) {
        if (!first) {
            if (!MultiLinesForPatterns)
                out.print(" ");
        } else
            first = false;
        out.print("(");
        if (qp.getGraph() == null)
            out.print("_");
        else
            WriterNode.output(out, qp.getGraph(), sCxt);
        out.print(" ");
        WriterNode.output(out, qp.getSubject(), sCxt);
        out.print(" ");
        WriterNode.output(out, qp.getPredicate(), sCxt);
        out.print(" ");
        WriterNode.output(out, qp.getObject(), sCxt);
        out.print(")");
        if (MultiLinesForPatterns)
            out.println();
    }
}
Also used : SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) Quad(org.apache.jena.sparql.core.Quad)

Example 22 with SerializationContext

use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.

the class Explain method formatTriples.

private static void formatTriples(IndentedLineBuffer out, BasicPattern triples) {
    SerializationContext sCxt = SSE.sCxt(SSE.getPrefixMapWrite());
    boolean first = true;
    for (Triple qp : triples) {
        if (!first && !MultiLinesForPatterns)
            out.print(" ");
        first = false;
        WriterNode.outputPlain(out, qp, sCxt);
        if (MultiLinesForPatterns)
            out.println();
    }
}
Also used : SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) Triple(org.apache.jena.graph.Triple)

Aggregations

SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)22 IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)5 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)5 Triple (org.apache.jena.graph.Triple)3 PrefixMapping (org.apache.jena.shared.PrefixMapping)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 MatchResult (java.util.regex.MatchResult)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 TerminationException (jena.cmd.TerminationException)1 Node (org.apache.jena.graph.Node)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1 BasicPattern (org.apache.jena.sparql.core.BasicPattern)1 Prologue (org.apache.jena.sparql.core.Prologue)1 Quad (org.apache.jena.sparql.core.Quad)1 Plan (org.apache.jena.sparql.engine.Plan)1 QueryEngineFactory (org.apache.jena.sparql.engine.QueryEngineFactory)1 FmtExprSPARQL (org.apache.jena.sparql.serializer.FmtExprSPARQL)1 NodeToLabelMapBNode (org.apache.jena.sparql.util.NodeToLabelMapBNode)1 Test (org.junit.Test)1