Package org.apache.jena.riot.lang

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


            URI baseURI = step.getNode().getBaseURI();
            URL url = baseURI.resolve(href).toURL();
            URLConnection conn = url.openConnection();

            StreamRDF dest = StreamRDFLib.dataset(dataset.asDatasetGraph());
            LangRIOT parser = RiotReader.createParser(conn.getInputStream(), lang, href, dest);
            ErrorHandler handler = new ParserErrorHandler(href);
            ParserProfile prof = RiotLib.profile(lang, href, handler);
            parser.setProfile(prof);
            try {
                parser.parse();
            } catch (Exception e) {
                logger.warn("Parse error in RDFLoad document; processing partial document");
                logger.debug(e.getMessage(), e);
            }
            conn.getInputStream().close();
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

            public void flush() {}
            String formatNode(Node n) { return FmtUtils.stringForNode(n, sCxt) ; }
        } ;

        StreamRDF dest = StreamRDFLib.sinkQuads(sink) ;
        @SuppressWarnings("deprecation")
        LangRIOT parser = RiotReader.createParser(tokenizer, language, null, dest) ;
        // Don't resolve IRIs.  Do checking.
        parser.setProfile(RiotLib.profile(null, false, true, errorHandler)) ;
        return parser ;
    }
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 = NodeFactory.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

    // Check for all RiotReader
    public static void parse(HttpAction action, StreamRDF dest, InputStream input, Lang lang, String base) {
        // Need to adjust the error handler.
//        try { RDFDataMgr.parse(dest, input, base, lang) ; }
//        catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
        LangRIOT parser = RiotReader.createParser(input, lang, base, dest) ;
        parser.getProfile().setHandler(errorHandler) ;
        try { parser.parse() ; }
        catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
    }
View Full Code Here

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

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

   
    @Test public void nquads_01()
    {
        Tokenizer tokenizer = TokenizerFactory.makeTokenizerString("<x> <p> <q> <g>.") ;
        CatchParserOutput sink = new CatchParserOutput() ;
        LangRIOT parser = RiotReader.createParserNQuads(tokenizer, 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

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.