Can specify separation character for getHeaderString
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java index 51060ef..011abef 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientRequestContext.java
@@ -184,14 +184,37 @@ * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value * class or using its {@code toString} method if a header delegate is not available. * + * This is a convenience method for {@code getHeaderString(name, ",")}. + * * @param name the message header. * @return the message header value. If the message header is not present then {@code 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. * @see #getHeaders() * @see #getStringHeaders() + * @see #getHeaderString(String, String) */ - public String getHeaderString(String name); + public default String getHeaderString(String name) { + return getHeaderString(name, ","); + } + + /** + * Get a message header as a single string value. + * + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * @param name the message header. + * @param separator the separation character. + * @return the message header value. If the message header is not present then {@code 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 the provided separation character. + * @see #getHeaders() + * @see #getStringHeaders() + * @since 4.0 + */ + public String getHeaderString(String name, String separator); /** * Checks whether a header with a specific name and value (or item of the token-separated value list) exists.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java index 5169f96..e679584 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/client/ClientResponseContext.java
@@ -81,13 +81,31 @@ /** * Get a message header as a single string value. * + * This is a convenience method for {@code getHeaderString(name, ",")}. + * * @param name the message header. * @return the message header value. If the message header is not present then {@code 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. * @see #getHeaders() + * @see #getHeaderString(String, String) */ - public String getHeaderString(String name); + public default String getHeaderString(String name) { + return getHeaderString(name, ","); + } + + /** + * Get a message header as a single string value. + * + * @param name the message header. + * @param separator the separation character. + * @return the message header value. If the message header is not present then {@code 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 the provided separation character. + * @see #getHeaders() + * @since 4.0 + */ + public String getHeaderString(String name, String separator); /** * Checks whether a header with a specific name and value (or item of the token-separated value list) exists.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java index bc91257..88aed79 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerRequestContext.java
@@ -221,13 +221,31 @@ /** * Get a message header as a single string value. * + * This is a convenience method for {@code getHeaderString(name, ",")}. + * * @param name the message header. * @return the message header value. If the message header is not present then {@code 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. * @see #getHeaders() + * @see #getHeaderString(String, String) */ - public String getHeaderString(String name); + public default String getHeaderString(String name) { + return getHeaderString(name, ","); + } + + /** + * Get a message header as a single string value. + * + * @param name the message header. + * @param separator the separation character. + * @return the message header value. If the message header is not present then {@code 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 the provided separation character. + * @see #getHeaders() + * @since 4.0 + */ + public String getHeaderString(String name, String separator); /** * Checks whether a header with a specific name and value (or item of the token-separated value list) exists.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java index f1e1562..9d71440 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/container/ContainerResponseContext.java
@@ -106,14 +106,37 @@ * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value * class or using its {@code toString} method if a header delegate is not available. * + * This is a convenience method for {@code getHeaderString(name, ",")}. + * * @param name the message header. * @return the message header value. If the message header is not present then {@code 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. * @see #getHeaders() * @see #getStringHeaders() + * @see #getHeaderString(String, String) */ - public String getHeaderString(String name); + public default String getHeaderString(String name) { + return getHeaderString(name, ","); + } + + /** + * Get a message header as a single string value. + * + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * @param name the message header. + * @param separator the separation character. + * @return the message header value. If the message header is not present then {@code 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 the provided separation character. + * @see #getHeaders() + * @see #getStringHeaders() + * @since 4.0 + */ + public String getHeaderString(String name, String separator); /** * Checks whether a header with a specific name and value (or item of the token-separated value list) exists.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java index 0506be4..1f27f82 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java
@@ -52,6 +52,8 @@ * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value * class or using its {@code toString} method if a header delegate is not available. * + * This is a convenience method for {@code getHeaderString(name, ",")}. + * * @param name the HTTP header. * @return the HTTP header value. If the HTTP header is not present then {@code 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 @@ -59,7 +61,27 @@ * @see #getRequestHeader(java.lang.String) * @since 2.0 */ - public String getHeaderString(String name); + public default String getHeaderString(String name) { + return getHeaderString(name, ","); + } + + /** + * <p> + * Get a HTTP header as a single string value. + * </p> + * Each single non-string header value is converted to String using a {@link jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one + * is available via {@link jakarta.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)} for the header value + * class or using its {@code toString} method if a header delegate is not available. + * + * @param name the HTTP header. + * @param separator the separation character. + * @return the HTTP header value. If the HTTP header is not present then {@code 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 the provided separation character. + * @see #getRequestHeader(java.lang.String) + * @since 4.0 + */ + public String getHeaderString(String name, String separator); /** * Checks whether a header with a specific name and value (or item of the token-separated value list) exists.