use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class BasicPattern method toString.
@Override
public String toString() {
IndentedLineBuffer out = new IndentedLineBuffer();
SerializationContext sCxt = SSE.sCxt(SSE.getPrefixMapString());
boolean first = true;
for (Triple t : triples) {
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();
return out.toString();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class QuadPattern method toString.
@Override
public String toString() {
IndentedLineBuffer out = new IndentedLineBuffer();
SerializationContext sCxt = SSE.sCxt((SSE.getPrefixMapWrite()));
boolean first = true;
for (Quad quad : quads) {
if (!first)
out.print(" ");
else
first = false;
// Adds (quad ...)
// SSE.write(buff.getIndentedWriter(), t) ;
out.print("(");
WriterNode.outputPlain(out, quad, sCxt);
out.print(")");
}
out.flush();
return out.toString();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class ExprUtils method fmtSPARQL.
public static String fmtSPARQL(ExprList exprs) {
IndentedLineBuffer buff = new IndentedLineBuffer();
fmtSPARQL(buff, exprs);
return buff.toString();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class QueryOutputUtils method toString.
// ---- PrintSerializable
public static String toString(PrintSerializable item, PrefixMapping pmap) {
IndentedLineBuffer buff = new IndentedLineBuffer();
SerializationContext sCxt = new SerializationContext(pmap);
item.output(buff, sCxt);
return buff.toString();
}
use of org.apache.jena.atlas.io.IndentedLineBuffer in project jena by apache.
the class QueryUtils method checkParse.
public static void checkParse(Query query) {
if (!SPARQLParserRegistry.get().containsFactory(query.getSyntax()))
return;
IndentedLineBuffer buff = new IndentedLineBuffer();
query.serialize(buff, query.getSyntax());
String tmp = buff.toString();
Query query2 = null;
try {
String baseURI = null;
if (!query.explicitlySetBaseURI())
// Not in query - use the same one (e.g. file read from) .
baseURI = query.getBaseURI();
query2 = QueryFactory.create(tmp, baseURI, query.getSyntax());
if (query2 == null)
return;
} catch (UnsupportedOperationException ex) {
// No parser after all.
return;
} catch (QueryException ex) {
System.err.println(tmp);
throw new QueryCheckException("could not parse output query", ex);
}
if (query.hashCode() != query2.hashCode())
throw new QueryCheckException("reparsed query hashCode does not equal parsed input query \nQuery (hashCode: " + query.hashCode() + ")=\n" + query + "\n\nQuery2 (hashCode: " + query2.hashCode() + ")=\n" + query2);
if (!query.equals(query2))
throw new QueryCheckException("reparsed output does not equal parsed input");
}
Aggregations