org.apache.abdera.protocol.server.util
Class ServerUtils

java.lang.Object
  extended by org.apache.abdera.protocol.server.util.ServerUtils

public class ServerUtils
extends java.lang.Object


Constructor Summary
ServerUtils()
           
 
Method Summary
static NamedWriter getAcceptableNamedWriter(Abdera abdera, java.lang.String accept_header)
          Returns an appropriate NamedWriter instance given an appropriately formatted HTTP Accept header.
static NamedWriter getNamedWriter(Abdera abdera, java.lang.String mediatype)
           
static java.lang.String[] orderByQ(java.lang.String header)
          Utility method for parsing HTTP content negotiation headers and sorting their tokens according to their q parameter values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerUtils

public ServerUtils()
Method Detail

orderByQ

public static java.lang.String[] orderByQ(java.lang.String header)

Utility method for parsing HTTP content negotiation headers and sorting their tokens according to their q parameter values.

e.g. Accept: audio/*; q=0.2, audio/basic, audio/mpeg; q=0.1

would sort into:

   audio/basic
   audio/*
   audio/mpeg
 


getAcceptableNamedWriter

public static NamedWriter getAcceptableNamedWriter(Abdera abdera,
                                                   java.lang.String accept_header)
Returns an appropriate NamedWriter instance given an appropriately formatted HTTP Accept header. The header will be parsed and sorted according to it's q parameter values. The first named writer capable of supporting the specified type, in order of q-value preference, will be returned. The results on this are not always predictable. For instance, if the Accept header says "application/*" it could end up with either the JSON writer or the PrettyXML writer, or any other writer that supports any writer that supports a specific form of "application/*". It's always best to be very specific in the Accept headers.


getNamedWriter

public static NamedWriter getNamedWriter(Abdera abdera,
                                         java.lang.String mediatype)