com.sun.jersey.server.impl.model
Class HttpHelper

java.lang.Object
  extended by com.sun.jersey.server.impl.model.HttpHelper

public final class HttpHelper
extends java.lang.Object

Helper classes for HTTP.

Author:
Paul.Sandoz@Sun.Com

Constructor Summary
HttpHelper()
           
 
Method Summary
static java.util.List<AcceptableMediaType> getAccept(HttpRequestContext request)
          Get the list of Media type from the "Accept" of an HTTP request.
static java.util.List<AcceptableMediaType> getAccept(HttpRequestContext request, java.util.List<QualitySourceMediaType> priorityMediaTypes)
           
static java.util.List<AcceptableToken> getAcceptCharset(HttpRequestContext request)
          Get the list of language tag from the "Accept-Charset" of an HTTP request.
static java.util.List<AcceptableToken> getAcceptEncoding(HttpRequestContext request)
          Get the list of language tag from the "Accept-Charset" of an HTTP request.
static java.util.List<AcceptableLanguageTag> getAcceptLangauge(HttpRequestContext request)
          Deprecated. see getAcceptLanguage(com.sun.jersey.api.core.HttpRequestContext).
static java.util.List<AcceptableLanguageTag> getAcceptLanguage(HttpRequestContext request)
          Get the list of language tag from the "Accept-Language" of an HTTP request.
static java.util.Locale getContentLanguageAsLocale(HttpRequestContext request)
          Get the content language as a Locale instance.
static javax.ws.rs.core.MediaType getContentType(HttpRequestContext request)
          Get the content type from the "Content-Type" of an HTTP request.
static javax.ws.rs.core.MediaType getContentType(java.lang.Object contentType)
          Get the content type from an Object.
static javax.ws.rs.core.MediaType getContentType(java.lang.String contentTypeString)
          Get the content type from a String.
static java.util.Set<MatchingEntityTag> getIfMatch(HttpRequestContext request)
           
static java.util.Set<MatchingEntityTag> getIfNoneMatch(HttpRequestContext request)
           
static java.util.Locale getLanguageTagAsLocale(java.lang.String language)
           
static boolean produces(javax.ws.rs.core.MediaType contentType, java.util.List<javax.ws.rs.core.MediaType> accept)
          Ascertain if an entity of a specific Media type is capable of being produced from a list of Media type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpHelper

public HttpHelper()
Method Detail

getContentType

public static javax.ws.rs.core.MediaType getContentType(HttpRequestContext request)
Get the content type from the "Content-Type" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The content type. If no "Content-Type is present then null is returned.

getContentType

public static javax.ws.rs.core.MediaType getContentType(java.lang.String contentTypeString)
Get the content type from a String.

Parameters:
contentTypeString - the content type as a String.
Returns:
The content type. If no "Content-Type is present then null is returned.

getContentType

public static javax.ws.rs.core.MediaType getContentType(java.lang.Object contentType)
Get the content type from an Object.

Parameters:
contentType - the content type as an Object.
Returns:
The content type. If no "Content-Type is present then null is returned.

getContentLanguageAsLocale

public static java.util.Locale getContentLanguageAsLocale(HttpRequestContext request)
Get the content language as a Locale instance.

Parameters:
request - The HTTP request.
Returns:
the content lanuage as a locale instance.

getLanguageTagAsLocale

public static java.util.Locale getLanguageTagAsLocale(java.lang.String language)

getIfMatch

public static java.util.Set<MatchingEntityTag> getIfMatch(HttpRequestContext request)

getIfNoneMatch

public static java.util.Set<MatchingEntityTag> getIfNoneMatch(HttpRequestContext request)

getAccept

public static java.util.List<AcceptableMediaType> getAccept(HttpRequestContext request)
Get the list of Media type from the "Accept" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The list of MediaType. This list is ordered with the highest quality acceptable Media type occuring first (see MediaTypes#ACCEPT_MEDIA_TYPE_COMPARATOR). If no "Accept" is present then a list with a single item of the Media type "\*\/*" is returned.

getAccept

public static java.util.List<AcceptableMediaType> getAccept(HttpRequestContext request,
                                                            java.util.List<QualitySourceMediaType> priorityMediaTypes)

getAcceptLangauge

@Deprecated
public static java.util.List<AcceptableLanguageTag> getAcceptLangauge(HttpRequestContext request)
Deprecated. see getAcceptLanguage(com.sun.jersey.api.core.HttpRequestContext).

Get the list of language tag from the "Accept-Language" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The list of LanguageTag. This list is ordered with the highest quality acceptable language tag occuring first.

getAcceptLanguage

public static java.util.List<AcceptableLanguageTag> getAcceptLanguage(HttpRequestContext request)
Get the list of language tag from the "Accept-Language" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The list of LanguageTag. This list is ordered with the highest quality acceptable language tag occuring first.

getAcceptCharset

public static java.util.List<AcceptableToken> getAcceptCharset(HttpRequestContext request)
Get the list of language tag from the "Accept-Charset" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The list of AcceptableToken. This list is ordered with the highest quality acceptable charset occuring first.

getAcceptEncoding

public static java.util.List<AcceptableToken> getAcceptEncoding(HttpRequestContext request)
Get the list of language tag from the "Accept-Charset" of an HTTP request.

Parameters:
request - The HTTP request.
Returns:
The list of AcceptableToken. This list is ordered with the highest quality acceptable charset occuring first.

produces

public static boolean produces(javax.ws.rs.core.MediaType contentType,
                               java.util.List<javax.ws.rs.core.MediaType> accept)
Ascertain if an entity of a specific Media type is capable of being produced from a list of Media type.

Parameters:
contentType - The Media type.
accept - The list of Media types of entities that may be produced. This list MUST be ordered with the highest quality acceptable Media type occuring first (see MediaTypes#ACCEPT_MEDIA_TYPE_COMPARATOR).
Returns:
true if the Media type can be produced, otherwise false.


Copyright © 2011 Sun Microsystems, Inc. All Rights Reserved.