org.glassfish.jersey.internal.inject
Class HttpHeadersInjectee

java.lang.Object
  extended by org.glassfish.jersey.internal.inject.HttpHeadersInjectee
All Implemented Interfaces:
HttpHeaders

public class HttpHeadersInjectee
extends Object
implements HttpHeaders

Proxiable wrapper for request scoped HttpHeaders instance.

Author:
Jakub Podlesak (jakub.podlesak at oracle.com)

Field Summary
 
Fields inherited from interface javax.ws.rs.core.HttpHeaders
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_ID, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPIRES, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LINK, LOCATION, RETRY_AFTER, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE
 
Constructor Summary
HttpHeadersInjectee()
           
 
Method Summary
 List<Locale> getAcceptableLanguages()
          Get a list of languages that are acceptable for the response.
 List<MediaType> getAcceptableMediaTypes()
          Get a list of media types that are acceptable for the response.
 Map<String,Cookie> getCookies()
          Get any cookies that accompanied the request.
 Date getDate()
          Get message date.
 String getHeaderString(String name)
          Get a HTTP header as a single string value.
 Locale getLanguage()
          Get the language of the request entity.
 int getLength()
          Get Content-Length value.
 MediaType getMediaType()
          Get the media type of the request entity.
 List<String> getRequestHeader(String name)
          Get the values of a HTTP request header.
 MultivaluedMap<String,String> getRequestHeaders()
          Get the values of HTTP request headers.
 void set(HttpHeaders httpHeaders)
          Set wrapped instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpHeadersInjectee

public HttpHeadersInjectee()
Method Detail

set

public void set(HttpHeaders httpHeaders)
Set wrapped instance. Should be invoked on each incoming request, when a new injectee instance is created by HK2.

Parameters:
httpHeaders - actual HttpHeaders instance.

getRequestHeader

public List<String> getRequestHeader(String name)
Description copied from interface: HttpHeaders
Get the values of a HTTP request header. The returned List is read-only. This is a shortcut for getRequestHeaders().get(name).

Specified by:
getRequestHeader in interface HttpHeaders
Parameters:
name - the header name, case insensitive.
Returns:
a read-only list of header values.

getHeaderString

public String getHeaderString(String name)
Description copied from interface: HttpHeaders
Get a HTTP header as a single string value.

Each single header value is converted to String using a RuntimeDelegate.HeaderDelegate if one is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the header value class or using its toString method if a header delegate is not available.

Specified by:
getHeaderString in interface HttpHeaders
Parameters:
name - the HTTP header.
Returns:
the HTTP header value. If the HTTP header is not present then null is returned. If the HTTP header is present but has no value then the empty string is returned. If the HTTP header is present more than once then the values of joined together and separated by a ',' character.
See Also:
HttpHeaders.getRequestHeader(java.lang.String)

getRequestHeaders

public MultivaluedMap<String,String> getRequestHeaders()
Description copied from interface: HttpHeaders
Get the values of HTTP request headers. The returned Map is case-insensitive wrt. keys and is read-only. The method never returns null.

Specified by:
getRequestHeaders in interface HttpHeaders
Returns:
a read-only map of header names and values.

getAcceptableMediaTypes

public List<MediaType> getAcceptableMediaTypes()
Description copied from interface: HttpHeaders
Get a list of media types that are acceptable for the response.

If no acceptable media types are specified, a read-only list containing a single wildcard media type instance is returned.

Specified by:
getAcceptableMediaTypes in interface HttpHeaders
Returns:
a read-only list of requested response media types sorted according to their q-value, with highest preference first.

getAcceptableLanguages

public List<Locale> getAcceptableLanguages()
Description copied from interface: HttpHeaders
Get a list of languages that are acceptable for the response.

If no acceptable languages are specified, a read-only list containing a single wildcard Locale instance (with language field set to "*") is returned.

Specified by:
getAcceptableLanguages in interface HttpHeaders
Returns:
a read-only list of acceptable languages sorted according to their q-value, with highest preference first.

getMediaType

public MediaType getMediaType()
Description copied from interface: HttpHeaders
Get the media type of the request entity.

Specified by:
getMediaType in interface HttpHeaders
Returns:
the media type or null if there is no request entity.

getLanguage

public Locale getLanguage()
Description copied from interface: HttpHeaders
Get the language of the request entity.

Specified by:
getLanguage in interface HttpHeaders
Returns:
the language of the entity or null if not specified.

getCookies

public Map<String,Cookie> getCookies()
Description copied from interface: HttpHeaders
Get any cookies that accompanied the request.

Specified by:
getCookies in interface HttpHeaders
Returns:
a read-only map of cookie name (String) to Cookie.

getDate

public Date getDate()
Description copied from interface: HttpHeaders
Get message date.

Specified by:
getDate in interface HttpHeaders
Returns:
the message date, otherwise null if not present.

getLength

public int getLength()
Description copied from interface: HttpHeaders
Get Content-Length value.

Specified by:
getLength in interface HttpHeaders
Returns:
Content-Length as integer if present and valid number. In other cases returns -1.


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.