Package org.openrdf.rio.helpers

Examples of org.openrdf.rio.helpers.StatementCollector


    try {
      RDFFormat format = Rio.getParserFormatForFileName(file.getName());
      RDFParser parser = Rio.createParser(format);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      InputStream stream = new FileInputStream(file);
      try {
        parser.parse(stream, file.toURI().toString());
      }
View Full Code Here


      RDFParser parser = Rio.createParser(rdfFormat);
      parser.setDatatypeHandling(DatatypeHandling.IGNORE);
      parser.setPreserveBNodeIDs(true);

      Set<Statement> result = new LinkedHashSet<Statement>();
      parser.setRDFHandler(new StatementCollector(result));

      InputStream in = new URL(resultFileURL).openStream();
      try {
        parser.parse(in, resultFileURL);
      }
View Full Code Here

  public static Model toGraph(TupleResult tqr)
    throws StoreException
  {
    Model model = new LinkedHashModel();
    DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(model));

    try {
      writer.startQueryResult(tqr.getBindingNames());
      while (tqr.hasNext()) {
        writer.handleSolution(tqr.next());
View Full Code Here

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
    }
View Full Code Here

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
    }
View Full Code Here

    protected RDFHandler getRDFHandlerForWriter(@Nullable RDFFormat format,
            Writer writer) throws OWLOntologyStorageException {
        // by default return a StatementCollector if they did not specify a
        // format
        if (format == null) {
            return new StatementCollector();
        } else {
            try {
                return Rio.createWriter(format, writer);
            } catch (final UnsupportedRDFormatException e) {
                throw new OWLOntologyStorageException(e);
View Full Code Here

            final RDFFormat format, final OutputStream outputStream)
            throws OWLOntologyStorageException {
        // by default return a StatementCollector if they did not specify a
        // format
        if (format == null) {
            return new StatementCollector();
        } else {
            try {
                return Rio.createWriter(format, outputStream);
            } catch (final UnsupportedRDFormatException e) {
                throw new OWLOntologyStorageException(e);
View Full Code Here

        testOntologyEmpty = testManager.createOntology(testOntologyUri1);
        testOntologyKoala = testManager
                .loadOntologyFromOntologyDocument(getClass()
                        .getResourceAsStream("/koala.owl"));
        assertEquals(70, testOntologyKoala.getAxiomCount());
        testHandlerStatementCollector = new StatementCollector();
        testOntologyEmptyStatement = vf
                .createStatement(vf.createURI("urn:test:ontology:uri:1"),
                        RDF.TYPE, OWL.ONTOLOGY);
        testRdfXmlStringWriter = new StringWriter();
        testRdfXmlRioWriter = Rio.createWriter(RDFFormat.RDFXML,
View Full Code Here

    rdfWriter.endRDF();

    StringReader reader = new StringReader(writer.toString());
    RDFParser rdfParser = rdfParserFactory.getParser();
    rdfParser.setValueFactory(vf);
    StatementCollector stCollector = new StatementCollector();
    rdfParser.setRDFHandler(stCollector);

    try {
      rdfParser.parse(reader, "foo:bar");
    }
    catch (RDFParseException e) {
      System.err.println("Failed to parse generated RDF document:");
      System.err.println(writer.toString());
      throw e;
    }

    Collection<Statement> statements = stCollector.getStatements();
    assertEquals("Unexpected number of statements", 1, statements.size());

    Statement parsedSt = statements.iterator().next();
    assertEquals("Written and parsed statements are not equal", st, parsedSt);
  }
View Full Code Here

    rdfWriter.endRDF();

    StringReader reader = new StringReader(writer.toString());
    RDFParser rdfParser = rdfParserFactory.getParser();
    rdfParser.setValueFactory(vf);
    StatementCollector stCollector = new StatementCollector();
    rdfParser.setRDFHandler(stCollector);

    try {
      rdfParser.parse(reader, "foo:bar");
    }
    catch (RDFParseException e) {
      System.err.println("Failed to parse generated RDF document:");
      System.err.println(writer.toString());
      throw e;
    }

    Collection<Statement> statements = stCollector.getStatements();
    assertEquals("Unexpected number of statements", 1, statements.size());

    Statement parsedSt = statements.iterator().next();
    assertEquals("Written and parsed statements are not equal", st, parsedSt);
  }
View Full Code Here

TOP

Related Classes of org.openrdf.rio.helpers.StatementCollector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.