public abstract class MessageHeaderMethods extends Object
Modifier and Type | Field and Description |
---|---|
protected RuntimeDelegate |
runtimeDelegateDecorator |
Modifier | Constructor and Description |
---|---|
protected |
MessageHeaderMethods(Configuration configuration) |
protected |
MessageHeaderMethods(MessageHeaderMethods other) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsHeaderString(String name,
Predicate<String> valuePredicate)
Checks whether a header with a specific name and value (or item of the comma-separated value list) exists.
|
boolean |
containsHeaderString(String name,
String valueSeparatorRegex,
Predicate<String> valuePredicate)
Checks whether a header with a specific name and value (or item of the token-separated value list) exists.
|
protected HeaderValueException |
exception(String headerName,
Object headerValue,
Exception e) |
Set<String> |
getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header.
|
Date |
getDate()
Get message date.
|
EntityTag |
getEntityTag()
Get the entity tag.
|
abstract MultivaluedMap<String,?> |
getHeaders()
Get the mutable message headers multivalued map.
|
abstract String |
getHeaderString(String name)
Get a message header as a single string value.
|
protected abstract HeaderValueException.Context |
getHeaderValueExceptionContext()
Return
HeaderValueException.Context type of the message context. |
Locale |
getLanguage()
Get the language of the entity.
|
Date |
getLastModified()
Get the last modified date.
|
int |
getLength()
Get Content-Length value.
|
long |
getLengthLong()
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. |
abstract Set<Link> |
getLinks()
Get the links attached to the message as header.
|
URI |
getLocation()
Get the location.
|
Map<String,Cookie> |
getRequestCookies()
Get any cookies that accompanied the message.
|
Map<String,NewCookie> |
getResponseCookies()
Get any new cookies set on the message.
|
boolean |
hasLink(String relation)
Check if link for relation exists.
|
protected <T> T |
singleHeader(String name,
Class<T> valueType,
Function<String,T> converter,
boolean convertNull)
Get a single typed header value.
|
protected <T> T |
singleHeader(String name,
Function<String,T> converter,
boolean convertNull)
Get a single typed header value for Inbound messages
|
protected RuntimeDelegate runtimeDelegateDecorator
protected MessageHeaderMethods(Configuration configuration)
protected MessageHeaderMethods(MessageHeaderMethods other)
public abstract String getHeaderString(String name)
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.name
- the message header.null
is returned. If the message
header is present but has no value then the empty string is returned. If the message header is present more than once
then the values of joined together and separated by a ',' character.public abstract MultivaluedMap<String,?> getHeaders()
protected abstract HeaderValueException.Context getHeaderValueExceptionContext()
HeaderValueException.Context
type of the message context.HeaderValueException.Context
type of the message context.public abstract Set<Link> getLinks()
Set
if no links are present. Never
returns null
.public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate<String> valuePredicate)
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.
For example: containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)
will return true
if
a Cache-Control
header exists that has the value no-store
, the value No-Store
or the value
Max-Age, NO-STORE, no-transform
, but false
when it has the value no-store;no-transform
(missing comma), or the value no - store
(whitespace within value).
name
- the message header.valueSeparatorRegex
- Separates the header value into single values. null
does not split.valuePredicate
- value must fulfil this predicate.true
if and only if a header with the given name exists, having either a whitespace-trimmed value
matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.public boolean containsHeaderString(String name, Predicate<String> valuePredicate)
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.
For example: containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)
will return true
if
a Cache-Control
header exists that has the value no-store
, the value No-Store
or the value
Max-Age, NO-STORE, no-transform
, but false
when it has the value no-store;no-transform
(missing comma), or the value no - store
(whitespace within value).
name
- the message header.valuePredicate
- value must fulfil this predicate.true
if and only if a header with the given name exists, having either a whitespace-trimmed value
matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.public Set<String> getAllowedMethods()
public Date getDate()
null
if not present.public EntityTag getEntityTag()
null
if not present.public Locale getLanguage()
null
if not specifiedpublic Date getLastModified()
null
if not present.public int getLength()
Note: getLengthLong()
should be preferred over this method, since it returns a long
instead and is therefore more portable.
-1
if negative number.ProcessingException
- when Integer.parseInt(String)
(String)} throws NumberFormatException
.public long getLengthLong()
-1
if negative number.ProcessingException
- when Long.parseLong(String)
throws NumberFormatException
.public Link getLink(String relation)
relation
- link relation.null
if not present.public Link.Builder getLinkBuilder(String relation)
Link.Builder
for the relation.relation
- link relation.null
if not
present.public URI getLocation()
null
if not present.public Map<String,Cookie> getRequestCookies()
Cookie
.public Map<String,NewCookie> getResponseCookies()
new cookie
.public boolean hasLink(String relation)
relation
- link relation.true
if the for the relation link exists, false
otherwise.protected <T> T singleHeader(String name, Class<T> valueType, Function<String,T> converter, boolean convertNull)
T
- header value type.name
- header name.valueType
- header value class.converter
- from string conversion function. Is expected to throw ProcessingException
if conversion fails.convertNull
- if true
this method calls the provided converter even for null
. Otherwise this
method returns the null
without calling the converter.null
if not present.protected <T> T singleHeader(String name, Function<String,T> converter, boolean convertNull)
T
- header value type.name
- header name.converter
- from string conversion function. Is expected to throw ProcessingException
if conversion fails.convertNull
- if true
this method calls the provided converter even for null
. Otherwise this
method returns the null
without calling the converter.null
if not present.protected HeaderValueException exception(String headerName, Object headerValue, Exception e)
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.