public static void printPrefixes(Prologue prologue, IndentedWriter out) {
    if (prologue.getPrefixMapping() == null) return;

    Map<String, String> pmap = null;

    if (prologue.getPrefixMapping() instanceof PrefixMapping2) {
      PrefixMapping2 pm2 = (PrefixMapping2) prologue.getPrefixMapping();
      pmap = pm2.getNsPrefixMap(false);
    } else {
      Map<String, String> _pmap = prologue.getPrefixMapping().getNsPrefixMap();
      pmap = _pmap;
    }

    if (pmap.size() > 0) {
      // boolean first = true ;
      for (String k : pmap.keySet()) {
        String v = pmap.get(k);
        out.print("PREFIX  ");
        out.print(k);
        out.print(':');
        out.print(' ', 4 - k.length());
        // Include at least one space
        out.print(' ');
        out.print(FmtUtils.stringForURI(v));
        out.newline();
      }
    }
  }
 private static void printBase(Prologue prologue, IndentedWriter out) {
   if (prologue.getBaseURI() != null && prologue.explicitlySetBaseURI()) {
     out.print("BASE    ");
     out.print("<" + prologue.getBaseURI() + ">");
     out.newline();
   }
 }
示例#3
0
    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 = new FormatterElement(out, sCxt);
        fmtElement.visitAsGroup(el);
      } else out.print("{}");
      out.decIndent(BLOCK_INDENT);
    }
示例#4
0
 private static void prologue(IndentedWriter out, Prologue prologue) {
   int row1 = out.getRow();
   PrologueSerializer.output(out, prologue);
   int row2 = out.getRow();
   if (row1 != row2) out.newline();
 }