uws
Class AcceptHeader

java.lang.Object
  extended by uws.AcceptHeader

public class AcceptHeader
extends java.lang.Object

Parser of HTTP Accept header. It takes into account the order of the different MIME types and their respective quality.

Version:
12/2010
Author:
Brice Gassmann (CDS) & modified by Grégory Mantelet (CDS)

Constructor Summary
AcceptHeader(java.lang.String acceptS)
          Parses the given value of the Accept field of HTTP request header.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.Float> getMimeTypes()
          Gets the association between each extracted MIME type and its respective quality.
 java.util.ArrayList<java.lang.String> getOrderedMimeTypes()
          Gets a list of the extracted MIME types, ordered by their respective quality.
 java.lang.String getPreferredMimeType()
          Gets the preferred MIME type (HTML, JSON or * /*) according to the order and the quality of all extracted MIME types.
 void setMimeTypes(java.util.Map<java.lang.String,java.lang.Float> mimeTypes)
          Sets the association between MIME types and their quality.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AcceptHeader

public AcceptHeader(java.lang.String acceptS)
Parses the given value of the Accept field of HTTP request header.

Parameters:
acceptS - The list of MIME types to parse.
Method Detail

getMimeTypes

public final java.util.Map<java.lang.String,java.lang.Float> getMimeTypes()
Gets the association between each extracted MIME type and its respective quality.

Returns:
Extracted MIME types and their quality.

setMimeTypes

public final void setMimeTypes(java.util.Map<java.lang.String,java.lang.Float> mimeTypes)
Sets the association between MIME types and their quality.

Parameters:
mimeTypes - MIME types and their quality.

getPreferredMimeType

public java.lang.String getPreferredMimeType()
Gets the preferred MIME type (HTML, JSON or * /*) according to the order and the quality of all extracted MIME types.

Returns:
application/xhtml+xml or text/html or text/xml or application/json or * /*.

getOrderedMimeTypes

public java.util.ArrayList<java.lang.String> getOrderedMimeTypes()
Gets a list of the extracted MIME types, ordered by their respective quality.

Returns:
The ordered list of the extracted MIME types.