use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class StatsMatcher method printSSE.
public void printSSE(OutputStream ps) {
IndentedWriter out = new IndentedWriter(ps);
out.println("(stats");
out.incIndent();
for (Pattern p : patterns) {
p.output(out);
out.println();
}
out.decIndent();
out.println(")");
out.flush();
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class SerializerRegistry method init.
private static synchronized void init() {
SerializerRegistry reg = new SerializerRegistry();
// Register standard serializers
QuerySerializerFactory arqQuerySerializerFactory = new QuerySerializerFactory() {
@Override
public QueryVisitor create(Syntax syntax, Prologue prologue, IndentedWriter writer) {
// For the query pattern
SerializationContext cxt1 = new SerializationContext(prologue, new NodeToLabelMapBNode("b", false));
// For the construct pattern
SerializationContext cxt2 = new SerializationContext(prologue, new NodeToLabelMapBNode("c", false));
return new QuerySerializer(writer, new FormatterElement(writer, cxt1), new FmtExprSPARQL(writer, cxt1), new FmtTemplate(writer, cxt2));
}
@Override
public QueryVisitor create(Syntax syntax, SerializationContext context, IndentedWriter writer) {
return new QuerySerializer(writer, new FormatterElement(writer, context), new FmtExprSPARQL(writer, context), new FmtTemplate(writer, context));
}
@Override
public boolean accept(Syntax syntax) {
// and SPARQL 1.1 can be serialized by the same serializer
return Syntax.syntaxARQ.equals(syntax) || Syntax.syntaxSPARQL_10.equals(syntax) || Syntax.syntaxSPARQL_11.equals(syntax);
}
};
reg.addQuerySerializer(Syntax.syntaxARQ, arqQuerySerializerFactory);
reg.addQuerySerializer(Syntax.syntaxSPARQL_10, arqQuerySerializerFactory);
reg.addQuerySerializer(Syntax.syntaxSPARQL_11, arqQuerySerializerFactory);
UpdateSerializerFactory arqUpdateSerializerFactory = new UpdateSerializerFactory() {
@Override
public UpdateSerializer create(Syntax syntax, Prologue prologue, IndentedWriter writer) {
if (!prologue.explicitlySetBaseURI())
prologue = new Prologue(prologue.getPrefixMapping());
SerializationContext context = new SerializationContext(prologue);
return new UpdateWriter(writer, context);
}
@Override
public boolean accept(Syntax syntax) {
// and SPARQL 1.1 can be serialized by the same serializer
return Syntax.syntaxARQ.equals(syntax) || Syntax.syntaxSPARQL_10.equals(syntax) || Syntax.syntaxSPARQL_11.equals(syntax);
}
};
reg.addUpdateSerializer(Syntax.syntaxARQ, arqUpdateSerializerFactory);
reg.addUpdateSerializer(Syntax.syntaxSPARQL_10, arqUpdateSerializerFactory);
reg.addUpdateSerializer(Syntax.syntaxSPARQL_11, arqUpdateSerializerFactory);
registry = reg;
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class JSON method write.
/**
* Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
*/
public static void write(OutputStream output, JsonValue jValue) {
IndentedWriter iOut = new IndentedWriter(output);
write(iOut, jValue);
iOut.flush();
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class RowSetWriterJSON method write.
@Override
public void write(OutputStream outStream, RowSet rowSet, Context context) {
IndentedWriter out = new IndentedWriter(outStream);
try {
ResultSetWriterTableJSON x = new ResultSetWriterTableJSON(out, context);
x.write(rowSet);
} finally {
IO.flush(out);
}
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class NodeFormatterTTL_MultiLine method writeLexicalMultiLine.
/**
* Output a string and run the Runnable at the same indentation level
*/
private void writeLexicalMultiLine(AWriter writer, String str, Runnable action) {
QuotedStringOutput escapeProc = chooseEscapeProcessor(str);
int indent = -1;
IndentedWriter iw = null;
if (writer instanceof IndentedWriter) {
iw = (IndentedWriter) writer;
iw.pad();
indent = iw.getAbsoluteIndent();
iw.setAbsoluteIndent(0);
}
escapeProc.writeStrMultiLine(writer, str);
if (action != null)
action.run();
if (indent >= 0)
iw.setAbsoluteIndent(indent);
}
Aggregations