javax.ws.rs.core
Interface ResponseHeaders


public interface ResponseHeaders

An injectable interface that provides access to HTTP response header information. This interface can only be injected as part of the response processing scope. Alternatively, the interface can be retrieved from a Response instance via its getHeaders() method.

Since:
2.0
Author:
Marek Potociar
See Also:
Context

Method Summary
 MultivaluedMap<String,String> asMap()
          Get the map of HTTP message header names to their respective values.
 Set<String> getAllowedMethods()
          Get the allowed HTTP methods from the Allow HTTP header.
 Map<String,NewCookie> getCookies()
          Get any new cookies set on the response message.
 Date getDate()
          Get message date.
 EntityTag getEntityTag()
          Get the entity tag.
 String getHeader(String name)
          Get a HTTP header as a single string value.
 List<String> getHeaderValues(String name)
          Get the values of a single HTTP message header.
 Locale getLanguage()
          Get the language of the entity
 Date getLastModified()
          Get the last modified date.
 int getLength()
          Get Content-Length value.
 Link getLink(String relation)
          Get the link for the relation.
 Link.Builder getLinkBuilder(String relation)
          Convenience method that returns a Link.Builder for the relation.
 Set<Link> getLinks()
          Get the links attached to the message as header.
 URI getLocation()
          Get the location.
 MediaType getMediaType()
          Get the media type of the entity
 boolean hasLink(String relation)
          Check if link for relation exists.
 

Method Detail

getAllowedMethods

Set<String> getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header.

Returns:
the allowed HTTP methods, all methods will returned as upper case strings.
Since:
2.0

getDate

Date getDate()
Get message date.

Returns:
the message date, otherwise null if not present.
Since:
2.0

getHeader

String getHeader(String name)
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.

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.
Since:
2.0
See Also:
asMap(), getHeaderValues(java.lang.String)

asMap

MultivaluedMap<String,String> asMap()
Get the map of HTTP message header names to their respective values. The returned map is case-insensitive wrt. keys and is read-only.

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.

Returns:
a read-only map of header names and values.
Throws:
IllegalStateException - if called outside of the message processing scope.
Since:
2.0
See Also:
getHeader(java.lang.String), getHeaderValues(java.lang.String)

getHeaderValues

List<String> getHeaderValues(String name)
Get the values of a single HTTP message header. The returned List is read-only. This is a convenience shortcut for asMap().get(name).

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.

Parameters:
name - the header name, case insensitive.
Returns:
a read-only list of header values.
Throws:
IllegalStateException - if called outside of the message processing scope.
Since:
2.0
See Also:
asMap(), getHeader(java.lang.String)

getLanguage

Locale getLanguage()
Get the language of the entity

Returns:
the language of the entity or null if not specified
Since:
2.0

getLength

int getLength()
Get Content-Length value.

Returns:
Content-Length as integer if present and valid number. In other cases returns -1.
Since:
2.0

getMediaType

MediaType getMediaType()
Get the media type of the entity

Returns:
the media type or null if there is no request entity.
Since:
2.0

getCookies

Map<String,NewCookie> getCookies()
Get any new cookies set on the response message.

Returns:
a read-only map of cookie name (String) to Cookie.
Since:
2.0

getEntityTag

EntityTag getEntityTag()
Get the entity tag.

Returns:
the entity tag, otherwise null if not present.
Since:
2.0

getLastModified

Date getLastModified()
Get the last modified date.

Returns:
the last modified date, otherwise null if not present.
Since:
2.0

getLocation

URI getLocation()
Get the location.

Returns:
the location URI, otherwise null if not present.
Since:
2.0

getLinks

Set<Link> getLinks()
Get the links attached to the message as header.

Returns:
links, may return empty Set if no links are present. Never returns null.
Since:
2.0

hasLink

boolean hasLink(String relation)
Check if link for relation exists.

Parameters:
relation - link relation.
Returns:
outcome of boolean test.
Since:
2.0

getLink

Link getLink(String relation)
Get the link for the relation.

Parameters:
relation - link relation.
Returns:
the link for the relation, otherwise null if not present.
Since:
2.0

getLinkBuilder

Link.Builder getLinkBuilder(String relation)
Convenience method that returns a Link.Builder for the relation.

Parameters:
relation - link relation.
Returns:
the link builder for the relation, otherwise null if not present.
Since:
2.0


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.