Package org.apache.jena.riot.lang

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


            // 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

                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

    {
        // Not as good as from an InputStream - RDF/XML not supported
        ContentType ct = determineCT(base, null, lang) ;
        if ( ct == null )
            throw new RiotException("Failed to determine the triples content type: (URI="+base+" : hint="+lang+")") ;
        LangRIOT parser ;
        if ( lang == null )
            throw new RiotException("No language specificied") ;

        if ( RDFLanguages.sameLang(RDFLanguages.RDFXML, lang) )
            parser = LangRDFXML.create(in, base, base, ErrorHandlerFactory.errorHandlerStd, output) ;
        else
        {
            Tokenizer tokenizer =
                RDFLanguages.RDFJSON.equals(lang)?
                              new TokenizerJSON(PeekReader.make(in)) :  
                              TokenizerFactory.makeTokenizer(in) ;
            parser = RiotReader.createParser(tokenizer, lang, base, output) ;
        }
        parser.parse() ;
    }
View Full Code Here

   
    // java.io.Readers are NOT preferred.
    private static void process(StreamRDF dest, String base, Reader in, Lang hintLang, Context context)
    {
        Tokenizer tokenizer = TokenizerFactory.makeTokenizer(in) ;
        LangRIOT parser = RiotReader.createParser(tokenizer, hintLang, base, dest) ;
        parser.parse() ;
    }
View Full Code Here

   
    protected void parse(StreamRDF sink, String... strings )
    {
        String string = StrUtils.strjoin("\n", strings) ;
        Tokenizer tokenizer = tokenizer(string) ;
        LangRIOT parser = createParser(tokenizer(string), sink) ;
        parser.getProfile().setHandler(new ErrorHandlerEx()) ;
        parser.parse() ;
    }
View Full Code Here

    final protected void parseCheck(String... strings)
    {
        String string = StrUtils.strjoin("\n", strings) ;
        Tokenizer tokenizer = tokenizer(string) ;
        StreamRDFCounting sink = StreamRDFLib.count() ;
        LangRIOT x = RiotReader.createParserNQuads(tokenizer, sink) ;
        x.setProfile(RiotLib.profile(null, false, true, new ErrorHandlerEx())) ;
        x.parse() ;
    }
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

        }

        @Override
        public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) {
            if ( lang == CSV){
              LangRIOT parser = new LangCSV (in, baseURI, baseURI, ErrorHandlerFactory.getDefaultErrorHandler(),  output);
                if ( parserProfile != null )
                    parser.setProfile(parserProfile);
                if ( errorHandler != null )
                    parser.getProfile().setHandler(errorHandler) ;
                parser.parse() ;
            } else {
              throw new IllegalArgumentException("The Lang must be 'CSV'!");
            }

        }
View Full Code Here

        }

        @Override
        public void read(Reader in, String baseURI, ContentType ct, StreamRDF output, Context context) {
          if ( lang == CSV){
            LangRIOT parser = new LangCSV (in, baseURI, baseURI, ErrorHandlerFactory.getDefaultErrorHandler(),  output);
                if ( parserProfile != null )
                    parser.setProfile(parserProfile);
                if ( errorHandler != null )
                    parser.getProfile().setHandler(errorHandler) ;
            parser.parse() ;
          } else {
              throw new IllegalArgumentException("The Lang must be 'CSV'!");
            }
        }
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.