コード例 #1
0
  @Override
  public void sparqlConstruct(String query, OutputStream os) throws StreamException {
    try {
      Statement st = getConnection().createStatement();

      // TODO: evaluate
      logEnable(st, true, false);

      RecordStream rs =
          new ResultSetRecordStream(executeQuery(st, "SPARQL " + prefixes + " " + query));

      NtWriter nt = new NtWriter(os);

      Record r;
      while ((r = rs.getNext()) != null) {
        String s = "" + r.get("S");
        String p = "" + r.get("P");
        String o = "" + r.get("O");
        nt.writeStatement(s, p, o);
      }
      st.close();
    } catch (SQLException ex) {
      throw new StreamException(ex);
    } catch (IOException ex) {
      throw new StreamException(ex);
    }
  }
コード例 #2
0
  public void writeLiteral(String s, String p, Object o) throws IOException {
    if (validate) {
      if (strictValidator != null) {
        strictValidator.validateLiteral(s, p, o);
      }
      validateUri(s);
      validateUri(p);
    }

    stmtCount++;
    NtWriter.writeLiteral(os, s, p, o, escapeUnicode);
  }
コード例 #3
0
  public void writeLiteral(Object s, Object p, Object o) throws IOException {
    if (validate) {
      if (strictValidator != null) {
        strictValidator.validateLiteral(s, p, o);
      }
      validateUri(s.toString());
      validateUri(p.toString());
      validateLiteral(o);
    }

    stmtCount++;
    NtWriter.writeLiteral(os, s.toString(), p.toString(), o, escapeUnicode);
  }
コード例 #4
0
 private void writeResource(String s) throws IOException {
   NtWriter.writeResource(os, s);
 }