public final class HeaderUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
asHeaderString(List<Object> values,
RuntimeDelegate rd)
Converts a list of message header values to a single string value (with individual values separated by
','). |
static String |
asString(Object headerValue)
Deprecated.
|
static String |
asString(Object headerValue,
Configuration configuration)
Convert a message header value, represented as a general object, to it's
string representation.
|
static String |
asString(Object headerValue,
RuntimeDelegate rd)
Convert a message header value, represented as a general object, to it's
string representation.
|
static MultivaluedMap<String,String> |
asStringHeaders(MultivaluedMap<String,Object> headers)
Deprecated.
|
static MultivaluedMap<String,String> |
asStringHeaders(MultivaluedMap<String,Object> headers,
Configuration configuration)
Returns string view of passed headers.
|
static MultivaluedMap<String,String> |
asStringHeaders(MultivaluedMap<String,Object> headers,
RuntimeDelegate rd)
Returns string view of passed headers.
|
static Map<String,String> |
asStringHeadersSingleValue(MultivaluedMap<String,Object> headers)
Deprecated.
|
static Map<String,String> |
asStringHeadersSingleValue(MultivaluedMap<String,Object> headers,
Configuration configuration)
Transforms multi value map of headers to single
String value map. |
static List<String> |
asStringList(List<Object> headerValues)
Deprecated.
|
static List<String> |
asStringList(List<Object> headerValues,
Configuration configuration)
Returns string view of list of header values.
|
static List<String> |
asStringList(List<Object> headerValues,
RuntimeDelegate rd)
Returns string view of list of header values.
|
static void |
checkHeaderChanges(Map<String,String> headersSnapshot,
MultivaluedMap<String,Object> currentHeaders,
String connectorName)
Deprecated.
|
static void |
checkHeaderChanges(Map<String,String> headersSnapshot,
MultivaluedMap<String,Object> currentHeaders,
String connectorName,
Configuration configuration)
Compares two snapshots of headers from jersey
ClientRequest and logs WARNING in case of difference. |
static AbstractMultivaluedMap<String,String> |
createInbound()
Create an empty inbound message headers container.
|
static AbstractMultivaluedMap<String,Object> |
createOutbound()
Create an empty outbound message headers container.
|
static <V> MultivaluedMap<String,V> |
empty()
Get immutable empty message headers container.
|
static NewCookie |
getPreferredCookie(NewCookie first,
NewCookie second)
Compare two NewCookies having the same name.
|
public static AbstractMultivaluedMap<String,String> createInbound()
public static <V> MultivaluedMap<String,V> empty()
public static AbstractMultivaluedMap<String,Object> createOutbound()
public static String asString(Object headerValue, RuntimeDelegate rd)
null,
this method returns null.
This method defers to RuntimeDelegate.createHeaderDelegate(java.lang.Class<T>) to
obtain a RuntimeDelegate.HeaderDelegate or HeaderDelegateProvider
to convert the value to a String.
If neither is found then the toString()
method on the header object is utilized.
headerValue - the header value represented as an object.rd - runtime delegate instance to be used for header delegate
retrieval. If null, a default RuntimeDelegate
instance will be obtained and
used.null
if the supplied header value is null.public static String asString(Object headerValue, Configuration configuration)
null,
this method returns null.
This method defers to RuntimeDelegate.createHeaderDelegate(java.lang.Class<T>) to
obtain a RuntimeDelegate.HeaderDelegate or HeaderDelegateProvider
to convert the value to a String.
If neither is found then the toString()
method on the header object is utilized.
headerValue - the header value represented as an object.configuration - the Configuration that may contain
CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE
property preventing the HeaderDelegateProvider
to be used by the default RuntimeDelegate instance.null
if the supplied header value is null.public static List<String> asStringList(List<Object> headerValues, RuntimeDelegate rd)
headerValues - header values.rd - RuntimeDelegate instance or null (in that case RuntimeDelegate.getInstance()
will be called for before element conversion.public static List<String> asStringList(List<Object> headerValues, Configuration configuration)
headerValues - header values.configuration - the Configuration that may contain
CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE
property preventing the HeaderDelegateProvider
to be used by the default RuntimeDelegate instance.public static MultivaluedMap<String,String> asStringHeaders(MultivaluedMap<String,Object> headers, Configuration configuration)
headers - headers.configuration - the Configuration that may contain
CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE
property preventing the HeaderDelegateProvider
to be used by the default RuntimeDelegate instance.null if {code headers} input parameter is null.public static MultivaluedMap<String,String> asStringHeaders(MultivaluedMap<String,Object> headers, RuntimeDelegate rd)
headers - headers.rd - RuntimeDelegate instance or null (in that case RuntimeDelegate.getInstance()
will be called for before conversion of elements).null if {code headers} input parameter is null.public static Map<String,String> asStringHeadersSingleValue(MultivaluedMap<String,Object> headers, Configuration configuration)
String value map.
Returned map is immutable. Map values are formatted using method asHeaderString(List, RuntimeDelegate).headers - headers to be formattedconfiguration - the Configuration that may contain
CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE
property preventing the HeaderDelegateProvider
to be used by the default RuntimeDelegate instance.String value map or
null if headers input parameter is null.public static String asHeaderString(List<Object> values, RuntimeDelegate rd)
',').
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.values - list of individual header values.rd - RuntimeDelegate instance or null (in that case RuntimeDelegate.getInstance()
will be called for before conversion of elements).null,
null is returned. If the list of values is empty, an empty string is returned.public static void checkHeaderChanges(Map<String,String> headersSnapshot, MultivaluedMap<String,Object> currentHeaders, String connectorName, Configuration configuration)
ClientRequest and logs WARNING in case of difference.
Current container implementations does not support header modification in WriterInterceptor
and MessageBodyWriter. The method checks there are some newly added headers
(probably by WI or MBW) and logs WARNING message about it.headersSnapshot - first immutable snapshot of headerscurrentHeaders - current instance of headers tobe compared toconnectorName - name of connector the method is invoked from, used just in logged messageconfiguration - the Configuration that may contain
CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE
property preventing the HeaderDelegateProvider
to be used by the default RuntimeDelegate instance.public static NewCookie getPreferredCookie(NewCookie first, NewCookie second)
first - NewCookie to be compared.second - NewCookie to be compared.@Deprecated public static String asString(Object headerValue)
null,
this method returns null.headerValue - the header value represented as an object.null
if the supplied header value is null.asString(Object, Configuration)@Deprecated public static List<String> asStringList(List<Object> headerValues)
headerValues - header values.asStringList(List, Configuration)@Deprecated public static MultivaluedMap<String,String> asStringHeaders(MultivaluedMap<String,Object> headers)
headers - headers.null if {code headers} input parameter is null.asStringHeaders(MultivaluedMap, Configuration)@Deprecated public static Map<String,String> asStringHeadersSingleValue(MultivaluedMap<String,Object> headers)
String value map.
Returned map is immutable. Map values are formatted using method asHeaderString(List, RuntimeDelegate).headers - headers to be formattedString value map or
null if headers input parameter is null.asStringHeadersSingleValue(MultivaluedMap, Configuration)@Deprecated public static void checkHeaderChanges(Map<String,String> headersSnapshot, MultivaluedMap<String,Object> currentHeaders, String connectorName)
ClientRequest and logs WARNING in case of difference.
Current container implementations does not support header modification in WriterInterceptor
and MessageBodyWriter. The method checks there are some newly added headers
(probably by WI or MBW) and logs WARNING message about it.headersSnapshot - first immutable snapshot of headerscurrentHeaders - current instance of headers tobe compared toconnectorName - name of connector the method is invoked from, used just in logged messagecheckHeaderChanges(Map, MultivaluedMap, String, Configuration)Copyright © 2007-2024,Oracleand/or its affiliates.All Rights Reserved. Use is subject to license terms.