Search in sources :

Example 1 with FormatterElement

use of org.apache.jena.sparql.serializer.FormatterElement in project jena by apache.

the class UpdateWriterVisitor method visit.

@Override
public void visit(UpdateModify update) {
    out.ensureStartOfLine();
    if (update.getWithIRI() != null) {
        //out.ensureStartOfLine() ;
        out.print("WITH ");
        output(update.getWithIRI());
    }
    if (update.hasDeleteClause()) {
        List<Quad> deleteQuads = update.getDeleteQuads();
        out.ensureStartOfLine();
        out.print("DELETE ");
        outputQuadsBraced(deleteQuads);
    }
    if (update.hasInsertClause()) {
        List<Quad> insertQuads = update.getInsertQuads();
        out.ensureStartOfLine();
        out.print("INSERT ");
        outputQuadsBraced(insertQuads);
    }
    if (!update.hasInsertClause() && !update.hasDeleteClause()) {
        // Fake a clause to make it legal syntax.
        out.ensureStartOfLine();
        out.println("INSERT { }");
    }
    for (Node x : update.getUsing()) {
        out.ensureStartOfLine();
        out.print("USING ");
        output(x);
    }
    for (Node x : update.getUsingNamed()) {
        out.ensureStartOfLine();
        out.print("USING NAMED ");
        output(x);
    }
    Element el = update.getWherePattern();
    out.ensureStartOfLine();
    out.print("WHERE");
    out.incIndent(BLOCK_INDENT);
    out.newline();
    if (el != null) {
        FormatterElement fmtElement = prepareElementFormatter();
        fmtElement.visitAsGroup(el);
    } else
        out.print("{}");
    out.decIndent(BLOCK_INDENT);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Node(org.apache.jena.graph.Node) Element(org.apache.jena.sparql.syntax.Element) FormatterElement(org.apache.jena.sparql.serializer.FormatterElement) FormatterElement(org.apache.jena.sparql.serializer.FormatterElement)

Aggregations

Node (org.apache.jena.graph.Node)1 Quad (org.apache.jena.sparql.core.Quad)1 FormatterElement (org.apache.jena.sparql.serializer.FormatterElement)1 Element (org.apache.jena.sparql.syntax.Element)1