org.apache.any23.http
Class AcceptHeaderBuilder

java.lang.Object
  extended by org.apache.any23.http.AcceptHeaderBuilder

public class AcceptHeaderBuilder
extends Object

Concatenates a collection of MIME specs in "type/subtype;q=x.x" notation into an HTTP Accept header value, and removes duplicates and types covered by wildcards. For example, if the type list contains "text/*;q=0.5", then "text/plain;q=0.1" in the list will be ignored because it's already covered by the wildcard with a higher q value.

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
AcceptHeaderBuilder(Collection<MIMEType> mimeTypes)
           
 
Method Summary
static AcceptHeaderBuilder fromStrings(Collection<String> typesAsStrings)
           
 String getAcceptHeader()
          Builds and returns an accept header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AcceptHeaderBuilder

public AcceptHeaderBuilder(Collection<MIMEType> mimeTypes)
Method Detail

fromStrings

public static AcceptHeaderBuilder fromStrings(Collection<String> typesAsStrings)

getAcceptHeader

public String getAcceptHeader()
Builds and returns an accept header.

Throws:
IllegalArgumentException - if an input MIME type cannot be parsed.


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.