Package org.openjena.atlas.web

Examples of org.openjena.atlas.web.MediaRange


   
    public static AcceptList create(MediaType...acceptItems)
    {
        AcceptList accepList = new AcceptList() ;
        for ( MediaType mtype : acceptItems )
            accepList.ranges.add(new MediaRange(mtype)) ;
        return accepList ;
    }       
View Full Code Here


   
    public static AcceptList create(String... acceptStrings)
    {
        AcceptList accepList = new AcceptList() ;
        for ( int i = 0 ; i < acceptStrings.length ; i++ )
            accepList.ranges.add(new MediaRange(acceptStrings[i])) ;
        return accepList ;
    }
View Full Code Here

    {
        // Normally aItem is an offer - a concrete media type.
//        ensureSorted() ;
        // Search all, find best by specifivity, "q"(quality), and then first occurring if otherwise equal.
       
        MediaRange choice = null ;
       
        for ( MediaRange acceptItem : ranges )
        {
            if ( acceptItem.accepts(aItem) )
            {
                // Return the more grounded term
                // E.g. aItem = text/plain ; acceptItem = text/*
               
                if ( choice != null && choice.get_q() >= acceptItem.get_q() )
                    continue ;
                // Return the more grounded term
                // E.g. aItem = text/plain ; acceptItem = text/*
                // This looses any q
                if ( aItem.moreGroundedThan(acceptItem) )
                {
                    // Clone/change.
                    acceptItem = new MediaRange(aItem.getType(), aItem.getSubType(), acceptItem.getCharset()) ;
                }
                choice = acceptItem ;
            }
        }
        return choice ;
View Full Code Here

     * @return MediaType
     */
   
    static public MediaType match(AcceptList proposalList, AcceptList offerList)
    {
        MediaRange choice = null // From offerlist
        //MediaRange choice2 = null ; // From proposal (q value and text/*)
       
        for ( MediaRange offer : offerList.entries() )
        {
            MediaRange m = proposalList.match(offer) ;
            if ( m != null )
            {
                if ( choice != null && choice.get_q() >= m.get_q() )
                    continue ;
                choice = m ; 
            }
        }
        if ( choice == null )
View Full Code Here

        return new MediaType(choice);
    }
   
    public MediaRange first()
    {
        MediaRange choice = null ;
        for ( MediaRange acceptItem : ranges )
        {
            if ( choice != null && choice.get_q() >= acceptItem.get_q() )
                continue ;
            choice = acceptItem ;
        }
        return choice ;
    }
View Full Code Here

        String[] x = s.split(",") ;
        for ( int i = 0 ; i < x.length ; i++ )
        {
            if ( x[i].equals(""))
                continue ;
            MediaRange mType = new MediaRange(x[i]) ;
            ranges.add(mType) ;
        }
        return ranges ;
    }
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

   
    public AcceptList(MediaType...acceptItems)
    {
        ranges = new ArrayList<MediaRange>() ;
        for ( MediaType mtype : acceptItems )
            ranges.add(new MediaRange(mtype)) ;
    }       
View Full Code Here

   
    public AcceptList(String... acceptStrings)
    {
        ranges = new ArrayList<MediaRange>() ;
        for ( int i = 0 ; i < acceptStrings.length ; i++ )
            ranges.add(new MediaRange(acceptStrings[i])) ;
    }
View Full Code Here

    {
        // Normally aItem is an offer - a concrete media type.
//        ensureSorted() ;
        // Search all, find best by specifivity, "q"(quality), and then first occurring if otherwise equal.
       
        MediaRange choice = null ;
       
        for ( MediaRange acceptItem : ranges )
        {
            if ( acceptItem.accepts(aItem) )
            {
                // Return the more grounded term
                // E.g. aItem = text/plain ; acceptItem = text/*
               
                if ( choice != null && choice.get_q() >= acceptItem.get_q() )
                    continue ;
                // Return the more grounded term
                // E.g. aItem = text/plain ; acceptItem = text/*
                // This looses any q
                if ( aItem.moreGroundedThan(acceptItem) )
                {
                    // Clone.
                    acceptItem = new MediaRange(acceptItem) ;
                    // Copy type info
                    acceptItem.setType(aItem.getType()) ;
                    acceptItem.setSubType(aItem.getSubType()) ;
                }
                choice = acceptItem ;
View Full Code Here

TOP

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

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.