use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.
the class TestFmtUtils method formatPattern_2_triples.
@Test
public void formatPattern_2_triples() {
BasicPattern basicPattern = new BasicPattern();
basicPattern.add(getTriple());
basicPattern.add(getTriple2());
ByteArrayOutputStream os = new ByteArrayOutputStream();
try (IndentedWriter iw = new IndentedWriter(os)) {
SerializationContext sc = new SerializationContext();
FmtUtils.formatPattern(iw, basicPattern, sc);
}
assertEquals("<n1> <n2> \"l3\" .\n" + "<nb1> <nb2> \"lb3\" .", new String(os.toByteArray()));
}
use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.
the class QueryValidatorJSON method string.
private static String string(Query query, Op op) {
final SerializationContext sCxt = new SerializationContext(query);
IndentedLineBuffer out = new IndentedLineBuffer();
op.output(out, sCxt);
return out.asString();
}
use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.
the class QueryValidatorHTML method outputQueryOp.
private static void outputQueryOp(ServletOutputStream outStream, Query query, final Op op, boolean lineNumbers) throws IOException {
final SerializationContext sCxt = new SerializationContext(query);
output(outStream, out -> op.output(out, sCxt), lineNumbers);
}
use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.
the class QueryValidator method output.
private void output(ServletOutputStream outStream, Query query, final Op op, boolean lineNumbers) throws IOException {
final SerializationContext sCxt = new SerializationContext(query);
Content c = new Content() {
@Override
public void print(IndentedWriter out) {
op.output(out, sCxt);
}
};
output(outStream, c, lineNumbers);
}
use of org.apache.jena.sparql.serializer.SerializationContext in project jena by apache.
the class ParameterizedSparqlString method appendNode.
/**
* Appends a Node to the command text as a constant using appropriate
* formatting
*
* @param n
* Node to append
*/
public void appendNode(Node n) {
SerializationContext context = new SerializationContext(this.prefixes);
context.setBaseIRI(this.baseUri);
this.cmd.append(this.stringForNode(n, context));
}
Aggregations