Search in sources :

Example 56 with IndentedWriter

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

the class dumpnodes method dump.

public static void dump(OutputStream w, ObjectFile objFile) {
    // Better to hack the indexes?
    Iterator<Pair<NodeId, Node>> iter = all(objFile);
    long count = 0;
    try (IndentedWriter iw = new IndentedWriter(w)) {
        if (!iter.hasNext()) {
            iw.println("No nodes in the .dat file");
            return;
        }
        for (; iter.hasNext(); ) {
            Pair<NodeId, Node> pair = iter.next();
            iw.print(pair.car().toString());
            iw.print(" : ");
            // iw.print(pair.cdr()) ;
            Node n = pair.cdr();
            String $ = stringForNode(n);
            iw.print($);
            iw.println();
            count++;
        }
        iw.println();
        iw.printf("Total: " + count);
        iw.println();
        iw.flush();
    }
}
Also used : IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) Node(org.apache.jena.graph.Node) NodeId(org.apache.jena.tdb.store.NodeId) Pair(org.apache.jena.atlas.lib.Pair)

Example 57 with IndentedWriter

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

the class tdbreorder method print.

private static void print(BasicPattern bgp) {
    IndentedWriter out = IndentedWriter.stdout;
    PrefixMapping pmap = SSE.getPrefixMapWrite();
    SerializationContext sCxt = SSE.sCxt(pmap);
    boolean first = true;
    for (Triple t : bgp) {
        if (!first)
            out.print("\n");
        else
            first = false;
        // Adds (triple ...)
        // SSE.write(buff.getIndentedWriter(), t) ;
        out.print("(");
        WriterNode.outputPlain(out, t, sCxt);
        out.print(")");
    }
    out.flush();
}
Also used : IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) Triple(org.apache.jena.graph.Triple) PrefixMapping(org.apache.jena.shared.PrefixMapping)

Aggregations

IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)57 SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)5 TerminationException (org.apache.jena.cmd.TerminationException)4 Node (org.apache.jena.graph.Node)4 PrefixMapping (org.apache.jena.shared.PrefixMapping)4 CmdException (org.apache.jena.cmd.CmdException)3 Triple (org.apache.jena.graph.Triple)3 Syntax (org.apache.jena.query.Syntax)3 IOException (java.io.IOException)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 Pair (org.apache.jena.atlas.lib.Pair)2 RiotException (org.apache.jena.riot.RiotException)2 RiotNotFoundException (org.apache.jena.riot.RiotNotFoundException)2 NodeFormatter (org.apache.jena.riot.out.NodeFormatter)2 NodeFormatterTTL (org.apache.jena.riot.out.NodeFormatterTTL)2 JenaException (org.apache.jena.shared.JenaException)2 ARQException (org.apache.jena.sparql.ARQException)2 Var (org.apache.jena.sparql.core.Var)2 Plan (org.apache.jena.sparql.engine.Plan)2 Expr (org.apache.jena.sparql.expr.Expr)2