示例#1
0
  @Override
  public void handleStatement(Statement st) throws RDFHandlerException {
    if (!writingStarted) {
      throw new RuntimeException("Document writing has not yet been started");
    }

    try {
      // SUBJECT
      NTriplesUtil.append(st.getSubject(), writer);
      writer.write(" ");

      // PREDICATE
      NTriplesUtil.append(st.getPredicate(), writer);
      writer.write(" ");

      // OBJECT
      NTriplesUtil.append(st.getObject(), writer);

      if (null != st.getContext()) {
        writer.write(" ");
        NTriplesUtil.append(st.getContext(), writer);
      }

      writer.write(" .\n");
    } catch (IOException e) {
      throw new RDFHandlerException(e);
    }
  }
 @Test
 public void testWriteMultiLabelledDomainRDF() throws Exception {
   AbstractQuery q = new NativeMultiLabelledQuery(testOutput + "/dumpstore2");
   q.setGraph("http://www.testunit.com");
   q.addFileToRepository(
       "src/test/resources/unit_test_no_bc.nt",
       RDFFormat.N3,
       NTriplesUtil.parseResource("<http://www.testunit.com>", new MemValueFactory()));
   _assertDump(q, testOutput + "/dumpoutput2", "testWriteMultiLabelledDomainRDF");
 }
示例#3
0
  @Override
  public void handleStatement(Statement arg0) throws RDFHandlerException {

    try {

      _writer.write("<p>");
      NTriplesUtil.append(arg0.getSubject(), _writer);
      _writer.write(" ");
      NTriplesUtil.append(arg0.getPredicate(), _writer);
      _writer.write(" ");
      NTriplesUtil.append(arg0.getObject(), _writer);

      if (arg0.getContext() != null) {
        _writer.write(" ");
        NTriplesUtil.append(arg0.getContext(), _writer);
      }

      _writer.write(" .");
      _writer.write("<p/>");

    } catch (IOException e) {
      throw new RDFHandlerException(e);
    }
  }