Class HeadersUtils


  • public final class HeadersUtils
    extends java.lang.Object
    Provides utility methods related to Headers.
    • Constructor Detail

      • HeadersUtils

        private HeadersUtils()
    • Method Detail

      • getAllAsString

        public static <K,​V> java.util.List<java.lang.String> getAllAsString​(Headers<K,​V,​?> headers,
                                                                                  K name)
        Headers.get(Object) and convert each element of List to a String.
        Parameters:
        name - the name of the header to retrieve
        Returns:
        a List of header values or an empty List if no values are found.
      • getAsString

        public static <K,​V> java.lang.String getAsString​(Headers<K,​V,​?> headers,
                                                               K name)
        Headers.get(Object) and convert the result to a String.
        Parameters:
        headers - the headers to get the name from
        name - the name of the header to retrieve
        Returns:
        the first header value if the header is found. null if there's no such entry.
      • iteratorAsString

        public static java.util.Iterator<java.util.Map.Entry<java.lang.String,​java.lang.String>> iteratorAsString​(java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>> headers)
        Headers.iterator() which converts each Map.Entry's key and value to a String.
      • toString

        public static <K,​V> java.lang.String toString​(java.lang.Class<?> headersClass,
                                                            java.util.Iterator<java.util.Map.Entry<K,​V>> headersIt,
                                                            int size)
        Helper for implementing toString for DefaultHeaders and wrappers such as DefaultHttpHeaders.
        Parameters:
        headersClass - the class of headers
        headersIt - the iterator on the actual headers
        size - the size of the iterator
        Returns:
        a String representation of the headers
      • namesAsString

        public static java.util.Set<java.lang.String> namesAsString​(Headers<java.lang.CharSequence,​java.lang.CharSequence,​?> headers)
        Headers.names() and convert each element of Set to a String.
        Parameters:
        headers - the headers to get the names from
        Returns:
        a Set of header values or an empty Set if no values are found.