Package org.openrdf.rio.helpers

Examples of org.openrdf.rio.helpers.StatementCollector


  public static Graph toGraph(TupleQueryResult tqr)
    throws QueryEvaluationException
  {
    Graph graph = new GraphImpl();
    DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph));

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


      // Parse input data
      TurtleParser turtleParser = new TurtleParser();
      turtleParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> inputCollection = new LinkedHashSet<Statement>();
      StatementCollector inputCollector = new StatementCollector(inputCollection);
      turtleParser.setRDFHandler(inputCollector);

      InputStream in = inputURL.openStream();
      turtleParser.parse(in, baseURL);
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = outputURL.openStream();
      ntriplesParser.parse(in, baseURL);
      in.close();
View Full Code Here

        // Try parsing the input; this should result in an error being
        // reported.
        TurtleParser turtleParser = new TurtleParser();
        turtleParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

        turtleParser.setRDFHandler(new StatementCollector());

        InputStream in = inputURL.openStream();
        turtleParser.parse(in, baseURL);
        in.close();
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

     * @throws IOException
     * @throws RDFParseException
     */
    public static Statement[] parseRDF(RDFFormat format, InputStream is, String baseURI)
    throws RDFHandlerException, IOException, RDFParseException {
        final StatementCollector handler = new StatementCollector();
        final RDFParser parser = getParser(format);
        parser.setVerifyData(true);
        parser.setStopAtFirstError(true);
        parser.setPreserveBNodeIDs(true);
        parser.setRDFHandler(handler);
        parser.parse(is, baseURI);
        return handler.getStatements().toArray( new Statement[handler.getStatements().size()] );
    }
View Full Code Here

        final Graph graph = new LinkedHashModel();
        final ParseErrorCollector parseErrorListener = new ParseErrorCollector();
        final ParserConfig parserConfig = new ParserConfig();
        final SesameTripleCallback callback = new SesameTripleCallback(
                new StatementCollector(graph), ValueFactoryImpl.getInstance(), parserConfig,
                parseErrorListener);

        JsonLdProcessor.toRDF(input, callback);

        final Iterator<Statement> statements = graph.iterator();
View Full Code Here

        config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
        config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true);
        rdfParser.setParserConfig(config);
        rdfParser.setValueFactory(vf);
        Model model = new LinkedHashModel();
        rdfParser.setRDFHandler(new StatementCollector(model));

        rdfParser.parse(in, "foo:bar");

        assertEquals("Unexpected number of statements, found " + model.size(), 1, model.size());
View Full Code Here

    private ParserConfig parserConfig;

    private final ParseErrorListener parseErrorListener;

    public SesameTripleCallback() {
        this(new StatementCollector(new LinkedHashModel()));
    }
View Full Code Here

    }

    private static long benchmarkSemarglSesame(File path) throws SAXException, ParseException {
        System.out.println("Semargl-Sesame benchmark");
        AbstractModel model = new LinkedHashModel();
        StreamProcessor streamProcessor = new StreamProcessor(JsonLdParser.connect(SesameSink.connect(new StatementCollector(model))));

        List<File> files = listFiles(path);
        long time = System.nanoTime();
        for (File file : files) {
            streamProcessor.process(file, HTTP_EXAMPLE_COM);
View Full Code Here

    @BeforeClass
    public void init() {
        rdfXmlParserTest = new RdfXmlParserTest();
        rdfXmlParserTest.init();
        model = new LinkedHashModel();
        streamProcessor = new StreamProcessor(RdfXmlParser.connect(SesameSink.connect(new StatementCollector(model))));
    }
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.