Package org.openjena.atlas.web

Examples of org.openjena.atlas.web.MediaType


                choice = m ; 
            }
        }
        if ( choice == null )
            return null ;
        return new MediaType(choice);
    }
View Full Code Here


    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1

    static public MediaType parse(String contentType)
    {
        try {
            return new MediaType(contentType) ;
        } catch (RuntimeException ex) { return null ; }
    }
View Full Code Here

    /** Match a single media type against a header string */
    public static String match(String headerString, String mediaRangeStr)
    {
        AcceptList l = new AcceptList(headerString) ;
        MediaRange aItem = new MediaRange(mediaRangeStr) // MediaType
        MediaType m = l.match(aItem) ;
        if ( m == null )
            return null ;
        return m.toHeaderString() ;
    }
View Full Code Here

    {
        String a = httpRequest.getHeader(hAcceptCharset) ;
        if ( log.isDebugEnabled() )
            log.debug("Accept-Charset request: "+a) ;
       
        MediaType item = choose(a, myPrefs, defaultMediaType) ;
       
        if ( log.isDebugEnabled() )
            log.debug("Charset chosen: "+item) ;
   
        return item ;
View Full Code Here

    {
        String a = WebLib.getAccept(httpRequest) ;
        if ( log.isDebugEnabled() )
            log.debug("Accept request: "+a) ;
       
        MediaType item = choose(a, myPrefs, defaultMediaType) ;
   
        if ( log.isDebugEnabled() )
            log.debug("Content type chosen: "+item) ;
   
        return item ;
View Full Code Here

        AcceptList headerList = new AcceptList(headerString) ;
       
        if ( myPrefs == null )
            return headerList.first() ;
   
        MediaType i = AcceptList.match(headerList, myPrefs) ;
        if ( i == null )
            return defaultMediaType ;
        return i ;
    }
View Full Code Here

   
    private void testMatch(String header, String offer, String result)
    {
        AcceptList list1 = new AcceptList(header) ;
        AcceptList list2 = new AcceptList(offer) ;
        MediaType matchItem = AcceptList.match(list1, list2) ;

        if ( result == null )
        {
            assertNull("Match not null: from "+q(header)+" :: "+q(offer),
                       matchItem) ;
            return ;
        }
        assertNotNull("Match is null: expected "+q(result), matchItem) ;
        assertEquals("Match different", result, matchItem.toHeaderString()) ;
    }
View Full Code Here

                choice = m ; 
            }
        }
        if ( choice == null )
            return null ;
        return new MediaType(choice);
    }
View Full Code Here

    protected void doGet(HttpActionREST action)
    {
        if ( action.hasTarget() )
            errorBadRequest("Attempt to use GET for quads and name a graph") ;
        MediaType mediaType = contentNegotationQuads(action) ;
        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 {
View Full Code Here

        if ( action.hasTarget() )
            errorBadRequest("Attempt to use GET for quads and name a graph") ;
       
        action.beginRead() ;
        try {
            MediaType mediaType = contentNegotationQuads(action) ;
            success(action) ;
        } finally { action.endRead() ; }
    }
View Full Code Here

TOP

Related Classes of org.openjena.atlas.web.MediaType

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.