Package org.openjena.riot

Examples of org.openjena.riot.Lang


        {
            actualContentType = modelContentType;
        }
       
        //Try to select language appropriately here based on the model content type
        Lang lang = WebContent.contentTypeToLang(actualContentType);
        if (!lang.isTriples()) throw new QueryException("Endpoint returned Content Type: " + actualContentType + " which is not a valid RDF Graph syntax");
       
        return RiotReader.createIteratorTriples(in, lang, null);
    }
View Full Code Here


     * @param contentType
     */
    public void setModelContentType(String contentType)
    {
      //Check that this is a valid setting
      Lang lang = WebContent.contentTypeToLang(contentType);
      if (lang == null) throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not supported by RIOT");
      if (!lang.isTriples()) throw new IllegalArgumentException("Given Content Type '" + contentType + " is not a RDF Graph format");
     
      modelContentType = contentType;
    }
View Full Code Here

        if ( modLangParse.skipOnBadTerm() )
        {
            // TODO skipOnBadterm
        }
       
        Lang lang = selectLang(filename, Lang.NQUADS)
        LangHandler handler = dispatch.get(lang) ;
        if ( handler == null )
            throw new CmdException("Undefined language: "+lang) ;
       
        // If multiple files, choose the overall labels.
        if ( langHandlerOverall == null )
            langHandlerOverall = handler ;
        else
        {
            if ( langHandlerOverall != langHandlerAny )
            {
                if ( langHandlerOverall != handler )
                    langHandlerOverall = langHandlerAny ;
            }
        }
       
        // Make a flag.
        // Input and output subflags.
        // If input is "label, then output using NodeToLabel.createBNodeByLabelRaw() ;
        // else use NodeToLabel.createBNodeByLabel() ;
        // Also, as URI.
        final boolean labelsAsGiven = false ;
       
        SinkCounting<?> sink ;
        LangRIOT parser ;
       
        NodeToLabel labels = SyntaxLabels.createNodeToLabel() ;
        if ( labelsAsGiven )
            labels = NodeToLabel.createBNodeByLabelEncoded() ;
       
        // Uglyness because quads and triples aren't subtype of some Tuple<Node>
        // That would change a lot (Triples came several years before Quads).
       
        if ( lang.isTriples() )
        {
            Sink<Triple> s = SinkNull.create() ;
            if ( ! modLangParse.toBitBucket() )
                s = new SinkTripleOutput(output, null, labels) ;
            if ( setup != null )
                s = InfFactory.infTriples(s, setup) ;
           
            SinkCounting<Triple> sink2 = new SinkCounting<Triple>(s) ;
           
            if ( lang.equals(Lang.RDFXML) )
                // Adapter round ARP RDF/XML reader.
                parser = LangRDFXML.create(in, baseURI, filename, errHandler, sink2) ;
            else
                parser = RiotReader.createParserTriples(in, lang, baseURI, sink2) ;
           
View Full Code Here

        IO.flush(System.out);
    }

    private void processFile(String filename, Sink<Quad> sink)
    {
        Lang lang = filename.equals("-") ? Lang.NQUADS : Lang.guess(filename, Lang.NQUADS) ;
        String baseURI = IRILib.filenameToIRI(filename) ;
       
        if ( lang.isTriples() )
        {
            InputStream in = IO.openFile(filename) ;
            Sink<Triple> sink2 = new SinkExtendTriplesToQuads(sink) ;
            LangRIOT parser = RiotReader.createParserTriples(in, lang, baseURI, sink2) ;
            parser.parse() ;
View Full Code Here

    {
        if ( false )
        {
            for ( String url : urls )
            {
                Lang lang = Lang.guess(url) ;
                if ( lang != null && ! lang.isQuads() )
                    throw new TDBException("Not a triples language") ;
            }
        }
       
        if ( graph.getGraphNode() == null )
View Full Code Here

        } else if ("bz2".equalsIgnoreCase(FilenameUtils.getExtension(name))) {
            is = new BZip2CompressorInputStream(is);
            name = FilenameUtils.removeExtension(name);
            log.debug("   - from BZip2 Archive");
        }// TODO: No Zip Files inside Zip Files supported :o( ^^
        Lang format = Lang.guess(name);
        // For N-Triple we can use the TDBLoader
        if (format == null) {
            log.warn("ignore File {} because of unknown extension ");
            return ResourceState.IGNORED;
        } else if (format == Lang.NTRIPLES) {
View Full Code Here

        ServletOutputStream output ;
        try { output = action.response.getOutputStream() ; }
        catch (IOException ex) { errorOccurred(ex) ; output = null ; }
       
        TypedOutputStream out = new TypedOutputStream(output, mediaType) ;
        Lang lang = FusekiLib.langFromContentType(mediaType.getContentType()) ;

        if ( action.verbose )
            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s",
                                  action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
        if ( ! lang.isQuads() )
            errorBadRequest("Not a quads format: "+mediaType) ;
       
        action.beginRead() ;
        try {
            DatasetGraph dsg = action.getActiveDSG() ;
View Full Code Here

                    msg = "Accept: "+x+" : Not understood" ;
                SPARQL_ServletBase.error(HttpSC.NOT_ACCEPTABLE_406, msg) ;
            }
           
            TypedInputStream ts = new TypedInputStream(null, mimeType, WebContent.charsetUTF8) ;
            Lang lang = FusekiLib.langFromContentType(ts.getMediaType()) ;
            RDFWriter rdfw = FusekiLib.chooseWriter(lang) ;
                
            if ( rdfw instanceof RDFXMLWriterI )
                rdfw.setProperty("showXmlDeclaration", "true") ;
           
View Full Code Here

        ServletOutputStream output ;
        try { output = action.response.getOutputStream() ; }
        catch (IOException ex) { errorOccurred(ex) ; output = null ; }
       
        TypedOutputStream out = new TypedOutputStream(output, mediaType) ;
        Lang lang = FusekiLib.langFromContentType(mediaType.getContentType()) ;

        if ( action.verbose )
            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s",
                                  action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;

        action.beginRead() ;
        try {
            boolean exists = action.getTarget().exists() ;
            if ( ! exists )
View Full Code Here

    }
   
    // ** Worker.
    private static void readUtil(Graph graph, String uri, int limit)
    {
        Lang lang = Lang.guess(uri, Lang.RDFXML) ;
       
        Sink<Triple> sink = new SinkTriplesToGraph(graph) ;
        sink = new SinkLimited<Triple>(sink, limit) ;
       
        // TODO Conneg - awiting RIOT code upgrade.
View Full Code Here

TOP

Related Classes of org.openjena.riot.Lang

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.