Package org.apache.jena.riot.lang

Examples of org.apache.jena.riot.lang.LangRIOT


    @Test public void trig_01()
    {
        Tokenizer tokenizer = TokenizerFactory.makeTokenizerString("{ <x> <p> <q> }") ;
        CatchParserOutput sink = new CatchParserOutput() ;
        LangRIOT parser = RiotReader.createParserTriG(tokenizer, "http://base/", sink) ;
        parserSetup(parser) ;
        parser.parse();
        assertEquals(1, sink.startCalled) ;
        assertEquals(1, sink.finishCalled) ;
        assertEquals(0, sink.triples.size()) ;
        assertEquals(1, sink.quads.size()) ;
        assertEquals(0, sink.tuples.size()) ;
View Full Code Here


   
    @Test public void trig_02()
    {
        Tokenizer tokenizer = TokenizerFactory.makeTokenizerString("<g> { <x> <p> <q> }") ;
        CatchParserOutput sink = new CatchParserOutput() ;
        LangRIOT parser = RiotReader.createParserTriG(tokenizer, "http://base/", sink) ;
        parserSetup(parser) ;
        parser.parse();
        assertEquals(1, sink.startCalled) ;
        assertEquals(1, sink.finishCalled) ;
        assertEquals(0, sink.triples.size()) ;
        assertEquals(1, sink.quads.size()) ;
        assertEquals(0, sink.tuples.size()) ;
View Full Code Here

    private Graph parseAsRDFJSON (ByteArrayOutputStream bout)
    {
        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()) ;
        Graph graph = GraphFactory.createGraphMem() ;
        StreamRDF dest = StreamRDFLib.graph(graph) ;
        LangRIOT parser = RiotReader.createParserRdfJson(bin, dest) ;
        parser.parse() ;
        return graph ;
    }
View Full Code Here

    private static DatasetGraph parse(HttpActionREST action, Lang lang, String base, InputStream input)
    {
        Graph graphTmp = GraphFactory.createGraphMem() ;
       
        StreamRDF dest = StreamRDFLib.graph(graphTmp) ;
        LangRIOT parser = RiotReader.createParser(input, lang, base, dest) ;
        parser.getProfile().setHandler(errorHandler) ;
        try { parser.parse() ; }
        catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
        DatasetGraph dsgTmp = DatasetGraphFactory.create(graphTmp) ;
        return dsgTmp ;
    }
View Full Code Here

        action.beginWrite() ;
        try {
            String name = action.request.getRequestURL().toString() ;
            DatasetGraph dsg = action.getActiveDSG() ;
            StreamRDF dest = StreamRDFLib.dataset(dsg) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            action.commit();
            success(action) ;
        } catch (IOException ex) { action.abort() ; }
        finally { action.endWrite() ; }
    }
View Full Code Here

            // This should not be anythign other than the datasets name via this route. 
            String name = action.request.getRequestURL().toString() ;
            //log.info(format("[%d] ** Content-length: %d", action.id, action.request.getContentLength())) ; 
            Graph g = dsg.getDefaultGraph() ;
            StreamRDF dest = StreamRDFLib.graph(g) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            action.commit();
            success(action) ;
        } catch (IOException ex) { action.abort() ; }
        finally { action.endWrite() ; }
    }
View Full Code Here

                name = name+ "/"  ;
            name = name+(++counter) ;
            Node gn = Node.createURI(name) ;
            Graph g = dsg.getGraph(gn) ;
            StreamRDF dest = StreamRDFLib.graph(g) ;
            LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
            parser.parse() ;
            log.info(format("[%d] Location: %s", action.id, name)) ;
            action.response.setHeader("Location",  name) ;
            action.commit();
            successCreated(action) ;
        } catch (IOException ex) { action.abort() ; }
View Full Code Here

        {
            return new ReaderRIOT() {
                @Override
                public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context)
                {
                    LangRIOT parser = RiotReader.createParser(in, lang, baseURI, output) ;
                    parser.parse() ;
                }
            } ;
        }
View Full Code Here

                HttpEntity entity = response.getEntity() ;
                MediaType mt = MediaType.create(response.getFirstHeader(HttpNames.hContentType).getValue()) ;
                mt.getCharset() ;
                StreamRDF dest = StreamRDFLib.graph(g) ;
                InputStream in = entity.getContent() ;
                LangRIOT parser = createParser(in, baseIRI, dest) ;
                parser.parse() ;
                in.close() ;
                this.graph = g ;
            } catch (IOException ex) { IO.exception(ex) ; }
        }
View Full Code Here

           
            outStream.println("<h1>RIOT Parser Report</h1>") ;
            outStream.println("<p>Line and column numbers refer to original input</p>") ;
            outStream.println("<p>&nbsp;</p>") ;
            try {
                LangRIOT parser = setupParser(tokenizer, language, errorHandler, outStream) ;
                startFixed(outStream) ;
                RiotException exception = null ;
                try {
                    parser.parse() ;
                    System.out.flush() ;
                    System.err.flush() ;
                } catch (RiotException ex) { exception = ex ; }
            } finally
            {
View Full Code Here

TOP

Related Classes of org.apache.jena.riot.lang.LangRIOT

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.