use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class sse_query method exec.
@Override
protected void exec() {
Op op = modAlgebra.getOp();
if (op == null) {
System.err.println("No query expression to execute");
throw new TerminationException(9);
}
Dataset dataset = modDataset.getDataset();
// Check there is a dataset.
if (dataset == null)
dataset = DatasetFactory.createGeneral();
modTime.startTimer();
DatasetGraph dsg = dataset.asDatasetGraph();
if (printOp || printPlan) {
if (printOp) {
divider();
IndentedWriter out = new IndentedWriter(System.out, true);
op.output(out);
out.flush();
}
if (printPlan) {
QueryIterator qIter = Algebra.exec(op, dsg);
Plan plan = new PlanOp(op, null, qIter);
divider();
IndentedWriter out = new IndentedWriter(System.out, false);
plan.output(out);
out.flush();
}
// return ;
}
// Do not optimize. Execute as-is.
QueryExecUtils.execute(op, dsg, modResults.getResultsFormat());
long time = modTime.endTimer();
if (modTime.timingEnabled())
System.out.println("Time: " + modTime.timeStr(time));
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class ModContext method verbose.
public void verbose(PrintStream stream) {
IndentedWriter out = new IndentedWriter(stream);
verbose(out);
out.flush();
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class ShaclcWriter method print.
/**
* Write shapes in <a href="https://w3c.github.io/shacl/shacl-compact-syntax/">SHACL Compact Syntax</a> (July 2020).
*/
public static void print(OutputStream output, Shapes shapes) {
IndentedWriter out = new IndentedWriter(output);
out.setUnitIndent(4);
print(out, shapes);
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class ShexPrintable method print.
public default void print() {
IndentedWriter iOut = IndentedWriter.clone(IndentedWriter.stdout);
NodeFormatter nFmt = new NodeFormatterTTL(null, PrefixMapFactory.create(SSE.getPrefixMapRead()));
print(iOut, nFmt);
}
use of org.apache.jena.atlas.io.IndentedWriter in project jena by apache.
the class ExQuerySelect1 method main.
public static void main(String[] args) {
// Create the data.
// This wil be the background (unnamed) graph in the dataset.
Model model = createModel();
// First part or the query string
String prolog = "PREFIX dc: <" + DC.getURI() + ">";
// Query string.
String queryString = prolog + NL + "SELECT ?title WHERE {?x dc:title ?title}";
Query query = QueryFactory.create(queryString);
// Print with line numbers
query.serialize(new IndentedWriter(System.out, true));
System.out.println();
try (QueryExecution qexec = QueryExecutionFactory.create(query, model)) {
// Or QueryExecutionFactory.create(queryString, model) ;
System.out.println("Titles: ");
// Assumption: it's a SELECT query.
ResultSet rs = qexec.execSelect();
// The order of results is undefined.
for (; rs.hasNext(); ) {
QuerySolution rb = rs.nextSolution();
// Get title - variable names do not include the '?' (or '$')
RDFNode x = rb.get("title");
// Check the type of the result value
if (x.isLiteral()) {
Literal titleStr = (Literal) x;
System.out.println(" " + titleStr);
} else
System.out.println("Strange - not a literal: " + x);
}
}
}
Aggregations