Package org.apache.jena.atlas.web

Examples of org.apache.jena.atlas.web.ContentType


    // We could have had two step design - ReaderFactory-ReaderInstance
    // no - put the bruden on complicated readers, not everyone.
   
    private static void process(StreamRDF destination, TypedInputStream in, String baseUri, Lang hintLang, Context context)
    {
        ContentType ct = determineCT(baseUri, in.getContentType(), hintLang) ;
        if ( ct == null )
            throw new RiotException("Failed to determine the content type: (URI="+baseUri+" : stream="+in.getContentType()+" : hint="+hintLang+")") ;

        ReaderRIOT reader = getReader(ct) ;
        if ( reader == null )
            throw new RiotException("No parser registered for content type: "+ct.getContentType()) ;
        reader.read(in, baseUri, ct, destination, context) ;
    }
View Full Code Here


    // java.io.Readers are NOT preferred.
    private static void process(StreamRDF destination, Reader in, String baseUri, Lang lang, Context context )
    {
        // Not as good as from an InputStream
        ContentType ct = determineCT(baseUri, null, lang) ;
        if ( ct == null )
            throw new RiotException("Failed to determine the content type: (URI="+baseUri+" : hint="+lang+")") ;
        ReaderRIOT reader = getReader(ct) ;
        if ( reader == null )
            throw new RiotException("No parser registered for content type: "+ct.getContentType()) ;
        reader.read(in, baseUri, ct, destination, context) ;
    }
View Full Code Here

        return r.create(lang) ;
    }

    /** Determine the Lang, given the URI target, any content type header string and a hint */
    public static Lang determineLang(String target, String ctStr, Lang hintLang) {
        ContentType ct = determineCT(target, ctStr, hintLang) ;
        if ( ct == null )
            return hintLang ;
        Lang lang = RDFLanguages.contentTypeToLang(ct) ;
        if (lang == null )
            return hintLang ;
View Full Code Here

        // If it's text plain, we ignore it because a lot of naive
        // server setups return text/plain for any file type.
        // (It was never registered as being N-triples;
        // that was only for RDF 2004 testing.)
        ContentType ct = null ;
        if ( ! isTextPlain )
            // Not guaranteed to be registered as a language here.
            ct = (ctStr==null) ? null : ContentType.create(ctStr) ;
       
        if ( ct == null && hintLang != null )
View Full Code Here

    {
        // I ti s shame we effectively duplicate deciding thelnaguage but we want to control the
        // pasrer at a deep level (in validation, we want line numbers get into error message)
        // This code predates RDFDataMgr.
       
        ContentType ct = in.getMediaType() ;
       
        baseURI = SysRIOT.chooseBaseIRI(baseURI, filename) ;
       
        boolean checking = true ;
        if ( modLangParse.explicitChecking() )  checking = true ;
View Full Code Here

            InputStream in = IO.openFileEx(fn) ;

            if ( StreamManager.logAllLookups && log.isTraceEnabled() )
                log.trace("Found: "+filenameIRI+thisDirLogStr) ;
           
            ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
            return new TypedInputStream(in, ct, filenameIRI) ;
        } catch (IOException ioEx)
        {
            // Includes FileNotFoundException
            // We already tested whether the file exists or not.
View Full Code Here

        }
       
        if ( StreamManager.logAllLookups  && log.isTraceEnabled() )
            log.trace("Found: "+resourceName) ;
       
        ContentType ct = RDFLanguages.guessContentType(resourceName) ;
        // No sensible base URI.
        return new TypedInputStream(in, ct, null) ;
    }
View Full Code Here

    public TypedInputStream performOpen(String uri) {
        if ( uri.startsWith("ftp://") ) {
            try {
                URL url = new URL(uri) ;
                InputStream in = url.openStream() ;
                ContentType ct = RDFLanguages.guessContentType(uri) ;
                return new TypedInputStream(in, ct) ;
            }
            catch (MalformedURLException ex) {
                throw new RiotException("Bad FTP URL: "+uri, ex) ;
            }
View Full Code Here

            }
           
            if ( StreamManager.logAllLookups  && log.isTraceEnabled() )
                log.trace("Found: "+filenameOrURI) ;
           
            ContentType ct = RDFLanguages.guessContentType(filenameOrURI) ;
            return new TypedInputStream(in, ct, filenameOrURI) ;
        }
        catch (IOException ex)
        {
            log.warn("IO Exception opening zip entry: " + filenameOrURI);
View Full Code Here

    // We could have had two step design - ReaderFactory-ReaderInstance
    // no - put the bruden on complicated readers, not everyone.
   
    private static void process(StreamRDF destination, TypedInputStream in, String baseUri, Lang hintLang, Context context)
    {
        ContentType ct = determineCT(baseUri, in.getContentType(), hintLang) ;
        if ( ct == null )
            throw new RiotException("Failed to determine the triples content type: (URI="+baseUri+" : stream="+in.getContentType()+" : hint="+hintLang+")") ;

        ReaderRIOT reader = getReader(ct) ;
        if ( reader == null )
            throw new RiotException("No triples reader for content type: "+ct.getContentType()) ;
        reader.read(in, baseUri, ct, destination, context) ;
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.atlas.web.ContentType

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.