Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can specify separation character for getHeaderString #1134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,37 @@ public default boolean hasProperty(String name) {
* 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 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);
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,31 @@ public interface ClientResponseContext {
/**
* 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 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);
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,31 @@ public default boolean hasProperty(String name) {
/**
* 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 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);
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,37 @@ public interface ContainerResponseContext {
* 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 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);
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.
Expand Down
24 changes: 23 additions & 1 deletion jaxrs-api/src/main/java/jakarta/ws/rs/core/HttpHeaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,36 @@ public interface HttpHeaders {
* 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
* values of joined together and separated by a ',' character.
* @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.
Expand Down